物体在产卵后停止

时间:2014-02-17 03:35:49

标签: unity3d master unityscript

function OnTriggerEnter(col : Collider)
{
    if(col.tag =="Player")
    {
        SpawnPoint.position = Vector3(transform.position.x, transform.position.y, transform.position.z);
    }
}

如何在产生检查点后停止对象的运行

1 个答案:

答案 0 :(得分:1)

我在answers.unity3d.com

发现了这个

你应该做的是简单地将刚体设置为运动学,以及brakeTorque将所有车轮碰撞器设置为Mathf.Infinity,然后下一次更新将其关闭,物理引擎应重置任何导致的力它要移动。

链接示例:

function FixedUpdate()
{
    // (if the vehicle has been respanwed this frame, 
    //        then a variable respawned is set to true)

    if (respawned)
    {
        wheelCol.brakeTorque = Mathf.Infinity;   // Repeat for all wheelcolliders
        rigidbody.isKinematic = true;
        respawned = false;
    }
    else
    {
        rigidbody.isKinematic = false;

        // (do the torque calculations here as usual)
    }
}