public class Collapse : MonoBehaviour
{
public Rigidbody rb;
public Rigidbody rb2;
public Rigidbody rb3;
void Start()
{
rb.useGravity = false;
rb2.useGravity = false;
rb3.useGravity = false;
}
void OnTriggerEnter(Collider coll)
{
if (coll.CompareTag("Player"))
{
rb.useGravity = true;
rb2.useGravity = true;
rb3.useGravity = true;
}
}
}
这是我到目前为止所拥有的,但似乎不起作用。当玩家越过某个扳机时,我基本上希望3个物体从天上掉下来,我已经设置了扳机并链接了3个刚体。启动功能起作用并禁用3个对象上的重力。但是我无法使第二部分起作用,在玩家越过扳机后,重力就不会重新启用。有人可以帮忙吗?
尝试此一个
void OnTriggerEnter(Collider coll)
{
if (coll.gameObject.CompareTag("Player"))
{
rb.useGravity = true;
rb2.useGravity = true;
rb3.useGravity = true;
}
}
问题:您无法从对撞机直接访问标签