|
|
|
@ -10,27 +10,28 @@ public class HMDControl : MonoBehaviour
|
|
|
|
|
public GameObject handleft;
|
|
|
|
|
public GameObject handright;
|
|
|
|
|
private int speed=1;
|
|
|
|
|
|
|
|
|
|
public float moveSpeed = 5f;
|
|
|
|
|
public float turnSpeed = 100f;
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
head.transform.position +=new Vector3(0,1,0) * 2.8f;
|
|
|
|
|
handright.transform.position = new Vector3(-0.77f, 0.94f, 2.1f);
|
|
|
|
|
handleft.transform.position = new Vector3(-0.47f, 0.94f, 1.5f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
// 获取水平和垂直输入
|
|
|
|
|
float h = Input.GetAxis("Horizontal");
|
|
|
|
|
float v = Input.GetAxis("Vertical");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float moveDirection = Input.GetAxis("Vertical"); // W 和 S 键
|
|
|
|
|
float turnDirection = Input.GetAxis("Horizontal"); // A 和 D 键
|
|
|
|
|
|
|
|
|
|
// 移动
|
|
|
|
|
head.transform.Translate(Vector3.forward * moveDirection * moveSpeed * Time.deltaTime, Space.Self);
|
|
|
|
|
|
|
|
|
|
// 根据输入移动物体
|
|
|
|
|
Vector3 movement = new Vector3(h, 0f, v);
|
|
|
|
|
head.transform.Translate(movement * speed * Time.deltaTime);
|
|
|
|
|
//handleft.transform.position = new Vector3(0.063f, 2.022f, 0.745f) ;
|
|
|
|
|
//handleft.transform.eulerAngles = new Vector3(-110, -80, -179);
|
|
|
|
|
// 转向
|
|
|
|
|
head.transform.Rotate(Vector3.up, turnDirection * turnSpeed * Time.deltaTime, Space.Self);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|