如何判断GameObject是否在移动?

时间:2017-04-30 09:39:25

标签: c# unity3d

好吧,我试过了:

{
    if(transform.position == m_transform) {
        stopped = true;
    }
    m_transform = transform.position;
}

但无论对象是否移动,stopped始终为true。我做错了什么?

2 个答案:

答案 0 :(得分:0)

我不能说太多,因为你没有分享很多代码,但从我看到的,你想要检测目标是否正在移动。

我认为这可以帮到你:

if(Vector3.Distance(transform.position, newTarget.position) < 0.1f){
    //target stopped
}

如此简单,如果目标在范围内(意味着距离非常小),那么我们假设他已经停止了。

答案 1 :(得分:0)

如果目标具有- src/main/resources/imsqti_v2p1.xsd - target - classes/org - imsglobal/... - Contains QTI .class files - w3_1998/math/mathml/... - Contains MathML .class files - src_managed/main/org - imsglobal/... - Contains generated QTI .java files - w3/_1998/math/mathml/... - Contains MathML .java files 组件,则可以检查

val mathmlPath = "org/w3/_1998/math/mathml"
def isInPath(path: String, file: File) = file.getCanonicalPath.startsWith(mathmlPath)
(managedSources in Compile) := managedSources.value.filterNot(file => isInPath(mathmlPath,file))

您还可以检查目标变换是否已更改 -

RigidBody
相关问题