赞
踩
1.Unity某个物体始终朝向相机
- Quaternion q = Quaternion.identity;
- q.SetLookRotation(Camera.main.transform.forward, Camera.main.transform.up);
- goName.transform.rotation = q;
2.相机随鼠标转动,地平线还始终水平
- void Update()
- {
- float hor = Input.GetAxis("Mouse X") * Rotatespeed;
- float ver = Input.GetAxis("Mouse Y") * Rotatespeed;
-
- Vector3 forward = Quaternion.Euler(-ver, hor, 0) * Camera.main.transform.forward;
- Camera.main.transform.rotation = Quaternion.LookRotation(forward, Vector3.up);
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。