- Home /
Trigger code is doing nothing
Hello!
Sorry for the vague title, couldn't decide how to phrase my problem. The following code prints nothing when LasarCollider comes in contact with an object whose parent is Asteroids.
Please help, I have been stuck on this all day.
private void OnTriggerEnter(Collider LasarCollider) { if (LasarCollider.transform.parent.tag == "Asteroids") { print("hi"); } }
Answer by zero_null · Dec 26, 2017 at 07:49 AM
Notes: Trigger events are only sent if one of the Colliders also has a Rigidbody attached.
Please see here more ! https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
Either you have a typo in your function name, or you don't have a rigidbody or you are mixing 2d with 3d physics..
Your answer
Follow this Question
Related Questions
How to add colliders to an array, and pick the oldest one? 1 Answer
GUI script problem with trigger enter. 1 Answer
OnTriggerExit wont work 1 Answer
Problem for moving an object with a button 0 Answers
Collecting 2 items at a time by mistake. 0 Answers