[Comment] Do not call references to other game objects "otherGameObject"

In the Lizard script’s OnTriggerEnter2D, I called my reference to “other.gameObject” what I thought was the sensible name “otherGameObject”.

DO NOT DO THIS! While it’s perfectly legal and your code will compile, it would appear that “otherGameObject” is reserved for Unity’s own uses, and it then gets confused and nothing works.

So in short, if you’re going to create a reference to another game object like a defender, then maybe call it “defenderGameObject” or such, and not “otherGameObject”, unless you’re especially keen on debugging obscure issues.

1 Like

Privacy & Terms