void OnTriggerEnter2D(Collider2D other) ..... What is is "other" called as ???

Is it a variable or datatype. Can’t i use any other than “OTHER” ??

2 Answers

2

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.

I think I see what you've done. You don't need to use the code you had for changing the color component etc. You literally just adjust the .alpha on the CanvasGroup. Thats the only thing you need to change. The examples I used above were just individual examples of different controls, I hoped you'd be able to incorporate that into your fade routine, but i'll provide the fade script too :) IEnumerator FadeCanvas() { for (float i = 1; i >0; i -= Time.deltaTime) { canvas.alpha = i; yield return null; } }

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: Unity - Scripting API: Collider2D

If it’s any help you can do other.gameObject to get the gameobject it’s attached to

Thank you soo much that works a treat! I think on my initial testing of your answer I forgot to call the IEnumerator method with the StartCoroutine call - hence the lack of any fade. I've got it working now. So once again thank you!!!