Object Collider is calling the wrong code

Hello there, I am pretty new to development and I’m attempting to make a 2D platformer for practice. I have gems in my game that trigger code to load the next scene when all of them are collected, and Obstacle objects with the name “KillPlayer” which are supposed to reload the current scene if they collide with my Player object.
It seems like the code for the gems and obstacles are interacting with each other. (like the obstacle is triggering the gem script.) I feel like this has something to do with the colliders that I don’t quite understand yet.
Also I want to mention that my Player object is made up of two colliders. I feel like that might be part of the issue.

Here is the link to my project in GitHub.

The project folder is Titled 2D Movement and animation.
My issue happens on all of my scenes, but the important one is the scene Titled LevelTest. this is the only one that has instances of the Gems I was talking about.


Welcome to our community! :slight_smile:

I’ve taken a brief look at your project, and you seem to have put a lot of time and effort into it. This also means that there are many lines of code. When seeking help for a specific problem, I would recommend to always share more information on the specific problem, not just the entire project. People who might want to help you are usually busy with their own projects and do not have time to read thousands of lines of code to hopefully find the lines you mean.

Since you already have a theory what might be causing the issue, try to analyse the situation with Debug.Logs. If you suspect the “wrong” colliders to interact with one another, log the name of the involved game objects into your console.

If you want to have colliders not interact with one another, you could use the layer-based collision matrix.

I hope this helped a bit. Please feel free to ask our helpful community of students for further advice over on our Discord chat server.

Good luck! :slight_smile: