Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用摄影机脚本在碰撞器处旋转角色_C#_Unity3d - Fatal编程技术网

C# 使用摄影机脚本在碰撞器处旋转角色

C# 使用摄影机脚本在碰撞器处旋转角色,c#,unity3d,C#,Unity3d,我使用一个简单的脚本让相机跟随玩家的目标 // Use this for initialization void Start() { //Calculate and store the offset value by getting the distance between the player's position and camera's position. offset = transform.position - player.transform.position; }

我使用一个简单的脚本让相机跟随玩家的目标

// Use this for initialization
void Start()
{
    //Calculate and store the offset value by getting the distance between the player's position and camera's position.
    offset = transform.position - player.transform.position;
}

// LateUpdate is called after Update each frame
void LateUpdate()
{
    // Set the position of the camera's transform to be the same as the player's, but offset by the calculated offset distance.
    transform.position = player.transform.position + offset;
}
但当我开始游戏时,玩家开始旋转,并在第一次击中对撞机时忽略对撞机


这是在我把这个脚本放到播放器上之后开始的。我甚至试图冻结旋转,但如果我冻结旋转,我就不能用动画旋转我的播放器。如何修复此问题?

将此脚本附加到“相机”而不是“播放器”,您应该会没事的