how to test if something enters a specific trigger and set that object to a gameobject variable!?!?
how to test if something enters a specific trigger and set that object to a gameobject variable!?!?
I want this because i want to know exactly what entered the trigger and what thing i should have to attack. I'm finding it very difficult at the moment but really need it. Its probably simple but i am a bit of a noob. Thanks in Advance for the help!
Answer by SteenPetersen · May 09, 2017 at 03:19 PM
You can test if something enters by simply putting a:
OnCollisionEnter(Collider other){
Debug.Log("I have collided with " + other.name);
}
remember to put collider2D if its a 2D collider you're using.
https://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html
Thanks but the code when i run it doesn't work but it's nice you tried thanks!
did you read the unity documentation I linked you?
I'll have a look again but thanks for trying to help me i'm a real noob with some mates making a very complex game!