Error message for (Collision other)

Hey Hey!

I’ve just completed this section of the course, however, I encountered an issue in the tutorial. I’ve resolved it myself, however, I’m not certain why my solution differs from Rick’s example.

Here is the code in question:

    void OnCollisionEnter(Collision other)

For my OnCollisionEnter method, I receive the following error statement.

Script error: OnCollisionEnter
This message parameter has to be of type: Collision
The message will be ignored.

The solution was to change the reference to…

    void OnCollisionEnter(UnityEngine.Collision other)

Does anyone know why I was required to add UnityEngine while Rick was not?

Thank you!

Can you show your include statements, im assuming there is a conflict on a Collision Object.

You can alright right click on Collision and go to definition to see what library it is referencing.

Hi,

Welcome to our community! :slight_smile:

I noticed that some students named their own class Collision. That would cause a conflict with the already existing Collision class/type in the UnityEngine namespace. Could it be that you named one of your classes Collision?

2 Likes

Hi Nina. Yes, I believe that is the issue. The C# script Collision.

Thank you!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms