My 2d object isnt acting as a trigger
Im trying to make a object re spawn when it falls out of the cameras view. I have set the object im using as a trigger & ive set my players tag to player. Idk what the problem is. Im bad at coding so pls keep the talk simple. Thanks in advance. hears my code public class Respawn : MonoBehaviour { [SerializeField] private Transform player; [SerializeField] private Transform respawnPoint;
void OnTriggerEnter2D(Collider2D other)
{
player.transform.position = respawnPoint.transform.position;
}
}
Hi @thesavvycow - $$anonymous$$ake sure that either your player or the other object has also a Rigidbody. $$anonymous$$ake sure that the collision layers are setup so that collision between player and trigger box object are registered. Also, make sure both are using either 3D or 2D system components, as they are different systems.
See: https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
Unity's tutorial on triggers: https://youtu.be/m0fjrQkaES4
Your answer
![](https://koobas.hobune.stream/wayback/20220612173404im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
shader graph help 1 Answer
Dragging child item in Horizontal Layout Group 0 Answers
rb.moveposition cant do diagonals 0 Answers