【发布时间】:2020-03-20 21:10:48
【问题描述】:
我有一个统一制作的游戏,地铁冲浪者喜欢,一切都完成了,但是: 在笔记本电脑上,我可以使用左右箭头键来移动播放器,但在手机上我不能,没有按钮,没有倾斜,没有滑动,什么都没有。 我在这里附上了我的脚本,请帮助我进行一些控件,但要与左右相同。 谢谢!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[Range(-2, 2)] public float value;
public float Speed;
Rigidbody rigid;
private Transform player;
private Vector3 desiredPosition;
void Start()
{
rigid = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
transform.position = new Vector3(value, transform.position.y, transform.position.z);
rigid.velocity = (Vector3.forward * Time.deltaTime * Speed);
}
private void LateUpdate()
{
if (Input.GetButtonDown("Right"))
{
if (value == 2)
return;
value += 2;
}
if (Input.GetButtonDown("Left"))
{
if (value == -2)
return;
value -= 2;
}
}
}
【问题讨论】:
-
这能回答你的问题吗? swipe gestures on android in unity
-
不,我在该主题中找不到答案。