O
O
OverLor12021-04-07 21:07:54
Unity
OverLor1, 2021-04-07 21:07:54

Why doesn't DeadZone(Trigger) work?

public class HereDead : MonoBehaviour
{
    public GameObject Player;
    public GameObject Ragdoll;
    void onTriggerEnter(Collider other)
    {
        if (other.tag == "DeadZone")
        {
            Player.SetActive(false);
            Ragdoll.SetActive(true);
            Instantiate(Ragdoll, transform.position, transform.rotation);
        }
    }
}

606deeaa18e50229074578.png
Cube has Trigger and Tag DeadZone.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
ZB Venom, 2021-04-07
@OverLor1

Isn't it necessary to define Player and Ragdoll ( respectively, in GameObject.Find specify their name on the stage )

public class HereDead : MonoBehaviour
{
    public GameObject Player;
    public GameObject Ragdoll;
    void onTriggerEnter(Collider other)
    {
        if (other.tag == "DeadZone")
        {
            Player = GameObject.Find("Player");
            Ragdoll = GameObject.Find("Ragdoll");
            Player.SetActive(false);
            Ragdoll.SetActive(true);
            Instantiate(Ragdoll, transform.position, transform.rotation);
        }
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question