【发布时间】:2018-06-03 07:06:08
【问题描述】:
我已经赋予了一个非活动刚体一个活动刚体的运动属性。在我的程序中,有必要删除活动对象并将其替换为非活动对象。当我这样做时,非活动对象会像活动对象一样停止移动。
{
inactive.SetActive(true);
inactive.transform.position = new Vector3(active.transform.position.x + 7.9f, active.transform.position.y, active.transform.position.z);
inactive.transform.rotation = new Quaternion(active.transform.rotation.x, active.transform.rotation.y, active.transform.rotation.z, active.transform.rotation.w);
inactive.GetComponent<Rigidbody>().AddTorque(0, 0, -active.transform.eulerAngles.z * Time.deltaTime);
inactive.GetComponent<Rigidbody>().AddForce(active.GetComponent<Rigidbody>().velocity.x * Time.deltaTime, active.GetComponent<Rigidbody>().velocity.y * Time.deltaTime, active.GetComponent<Rigidbody>().velocity.z * Time.deltaTime);
active.SetActive(false);
}
如果我拿出来就可以了
active.SetActive(false);
但我需要第一个对象消失。
这段代码在后期更新方法中
【问题讨论】:
标签: unity3d