试图冻结统一 3D 中的相机位置
Trying to freeze the camera location in unity 3D
我试图让摄像机跟随 unity 3D 中的玩家我将摄像机连接到玩家但它也随着他旋转因为他是一个球我不想发生这种情况我添加了一个刚体相机它曾经工作过一次 IDK 如何但后来由于刚体任何帮助它停止跟随他??
所以你已经让你的相机成为你播放器的child?如果是这样,相机将继承您播放器的所有转换,这绝对不是您想要的。您可以按照此视频学习相机跟随脚本。 https://www.youtube.com/watch?v=MFQhpwc6cKE
而且您几乎永远不需要在相机上放置刚体,因此您可以将其移除。
Child objects 总是继承 parent object 的变换,正如克里斯托弗已经说过的。因此,如果球在世界中滚动(在这种情况下由 RigidBody / 物理控制),您的相机也会旋转。
为了让摄像机跟随场景中的任何 object,您可以为摄像机使用一个单独的游戏对象,它跟随玩家 object,由一个简单的脚本控制。 - 例如像这样的东西(来自 Unity documentation 的修改示例):
using UnityEngine;
public class SmoothFollow : MonoBehaviour
{
public Transform target;
public float smoothTime = 0.3f;
public Vector3 offset = new Vector3(0.0f, 5.0f, -10.0f);
private Vector3 velocity = Vector3.zero;
void Update()
{
// Define a target position above and behind the target transform
Vector3 targetPosition = target.TransformPoint(offset);
// Smoothly move the camera towards that target position
transform.position = Vector3.SmoothDamp(transform.position,
targetPosition, ref velocity, smoothTime);
// Make the camera point towards the target
transform.LookAt(target);
}
}
(这是一个很基础的问题,之前已经回答过很多次了。你只要在网上搜索一下就可以很容易地找到很多类似的例子。-还有post的标题与问题不相符。重要的是要找到正确的词和提示,以保持本网站正常运行(明确的技术问题 -> 明确的答案)。)
我试图让摄像机跟随 unity 3D 中的玩家我将摄像机连接到玩家但它也随着他旋转因为他是一个球我不想发生这种情况我添加了一个刚体相机它曾经工作过一次 IDK 如何但后来由于刚体任何帮助它停止跟随他??
所以你已经让你的相机成为你播放器的child?如果是这样,相机将继承您播放器的所有转换,这绝对不是您想要的。您可以按照此视频学习相机跟随脚本。 https://www.youtube.com/watch?v=MFQhpwc6cKE
而且您几乎永远不需要在相机上放置刚体,因此您可以将其移除。
Child objects 总是继承 parent object 的变换,正如克里斯托弗已经说过的。因此,如果球在世界中滚动(在这种情况下由 RigidBody / 物理控制),您的相机也会旋转。
为了让摄像机跟随场景中的任何 object,您可以为摄像机使用一个单独的游戏对象,它跟随玩家 object,由一个简单的脚本控制。 - 例如像这样的东西(来自 Unity documentation 的修改示例):
using UnityEngine;
public class SmoothFollow : MonoBehaviour
{
public Transform target;
public float smoothTime = 0.3f;
public Vector3 offset = new Vector3(0.0f, 5.0f, -10.0f);
private Vector3 velocity = Vector3.zero;
void Update()
{
// Define a target position above and behind the target transform
Vector3 targetPosition = target.TransformPoint(offset);
// Smoothly move the camera towards that target position
transform.position = Vector3.SmoothDamp(transform.position,
targetPosition, ref velocity, smoothTime);
// Make the camera point towards the target
transform.LookAt(target);
}
}
(这是一个很基础的问题,之前已经回答过很多次了。你只要在网上搜索一下就可以很容易地找到很多类似的例子。-还有post的标题与问题不相符。重要的是要找到正确的词和提示,以保持本网站正常运行(明确的技术问题 -> 明确的答案)。)