【发布时间】:2015-11-05 02:40:28
【问题描述】:
我让一个角色在一个圆的表面上移动。我让相机移动和旋转跟随角色。但是相机移动和旋转非常不稳定。如果我增加第三个参数的值,冲击就会增加。并减少第三个参数的值,相机不旋转以跟上角色。帮我修一下
我的代码相机跟随玩家
public class CameraFollow : MonoBehaviour
{
public Transform player;
GameController gc;
public float speed = 2;
Vector3 pos = new Vector3 (0, 0, -10);
// Use this for initialization
void Start ()
{
gc = FindObjectOfType (typeof(GameController)) as GameController;
}
void FixedUpdate ()
{
if (gc.gameState == GameController.GameState.playing || gc.gameState == GameController.GameState.changeWave) {
transform.position = player.position + pos;
transform.rotation = Quaternion.Slerp (transform.rotation,
player.transform.rotation,
speed * Time.deltaTime);
}
}
}
【问题讨论】:
标签: unity3d game-physics