【发布时间】:2014-08-15 08:26:47
【问题描述】:
我正在触摸我的 Android 设备中的摄像头,它会随着触摸而移动,但我想限制它在 X 和 Y 轴上的移动,这是让我移动摄像头的代码。
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
public float speed = 0.1F;
void Update() {
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
transform.Translate(-touchDeltaPosition.x * speed * Time.deltaTime, - touchDeltaPosition.y * speed * Time.deltaTime, 0);
}
}
}
感谢您的帮助
【问题讨论】: