What is OnCollisionEx? Where is OnCollisionExit? and why does OnCollisionEx not work?

I am trying to make a moving platform and parent my player whenever he is standing on a moving object.

I am using Unity 5.6 and I can not find OnCollisionExit. So instead it seems that OnCollisionEx is the only option visible.

When I try using OnCollisionEx it is never called, even though OnCollisionEnter works as expected.

I even searched Google up and down trying to find even the slightest hint as to what OnCollisionEx was compared to OnCollisionExit but was unsuccessful and I only was able to find references to OnCollisionExit.

How do I use it and why is it not being called?

Thanks.

What do you mean only option visible? The function must be called OnCollisionExit in order to work. It’s not an override or anything, it’s a Unity “magic” function that you just define and Unity knows what to do with.

To get more information on these types of functions, refer to the MonoBehaviour reference.

Ok, it works but it was strange, I’m a sucker for using autocomplete and I always press ctrl+space when in MonoDevelop to see my options. When I did it this time it kept showing me a list containing OnCollisionEnter and OnCollisionEx. So there was a bug in the autocomplete list generation code or something… Either way it worked after I just typed out OnCollisionExit in it’s entirety.

You may have spelled OnCollisionExit as OnCollisionEx somewhere else and that’s where it’s picking it up.

I recommend ditching MonoDevelop though. It never works right for me, especially tab completion. I’ve been using VS Code (a lightweight editor from Microsoft) for a while now and it always just works. If you want to go whole hog you can install Visual Studio it works really well but take like 6 gigs of hard drive space.

1 Like

Visual Studio is purpose-built for writing C#, Monodevelop is a more general purpose IDE with much less intelligent code completion. Visual Studio directly analyses code to figure out what’s available rather than best-guessing it based on your past behaviour.

As a sidenote, Visual Studio is also jam-packed with other tools and keyboard shortcuts to make writing C# as easy as possible, you’ll be surprised at how productive you can be with a little practice!

Am I the only one that never has this sort of issue with MonoDevelop?

Mono always gave me issues. The worst being when tabs would break if I had multiple scripts open, I couldn’t switch between them. Constant crashes and many other issues. Our mac guy has all sorts of problems with it and I tell him to try one of the VS solutions that is on mac.

Also note that Visual Studios now includes a install option in 2017 to install only what you need for Unity. Or, Unity 5.6 includes the option to install VS 2017, which I would assume does the same thing. Takes a lot less space than 6 gigs (mine is under a gig)