gpt4 book ai didi

c# - 如何检查物体是否在移动

转载 作者:行者123 更新时间:2023-12-02 10:44:15 26 4
gpt4 key购买 nike

我正在尝试统一做一些事情,并且我需要知道相机是否在移动。

这是脚本:

GameObject MainCamara = GameObject.FindGameObjectWithTag("MainCamera");
NewPosition = new Vector3(player.position.x, player.position.y, -10);
positionChanging(NewPosition);
if (MainCamara.GetComponent<Rigidbody2D>() == null)
{
CameraMoving = true;
}
if (MainCamara.GetComponent<Rigidbody2D>().velocity.magnitude > 0.01f)
{
CameraMoving = true;
}
CameraMoving = false;

我没有收到任何错误,但它仍然不起作用

最佳答案

考虑使用:

Camera.main.velocity

来自Unity Documentation

关于c# - 如何检查物体是否在移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60364589/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com