- Home /
Question by
Nithinsvs · Oct 31, 2017 at 03:31 AM ·
collider2d
void OnTriggerEnter2D(Collider2D other) ..... What is is "other" called as ???
Is it a variable or datatype. Can't i use any other than "OTHER" ??
Comment
Answer by jchester07 · Oct 31, 2017 at 03:41 AM
Well, it's a variable with a type of Collider2D.
You can replace other to anything you want.
They must have used "other" since it's referring to the other Collider2d component that triggered the Collider2d of where the script is attached.
Answer by AidanHorton · Oct 31, 2017 at 12:31 PM
As said in other answers, 'other' is the name of the variable (that can be whatever you want), and it has data-type 'Collider2D' - Check the documentation here: https://docs.unity3d.com/ScriptReference/Collider2D.html
If it's any help you can do other.gameObject to get the gameobject it's attached to