Hi to everyone, I’m experiencing an issue that I can’t fix. I’ve checked tones of tutorials and they all say the same "check that both objects have collider and at least one of them a rigid body, and also the trigger object with isTrigered marked(I even tried rigid body on both with no gravity and iskinetic). Well, here is the thing I think they never collide for some reason, so I’ll leave some screenshots for you to please help me to make it work.
This is the player that will collide with the object.
Well we know that collision didn’t stop working, therefore something is wrong with the setup.
For one, your OnTriggerEnter is inside the Update(). That alone prevents anything else outside of Update() from seeing it, so from Unity’s standpoint your OnTriggerEnter doesn’t even exist.
Coding requires that 100% of everything is put in precisely the correct spot, not just sorta all in one big giant blob of things.
Again, we know that collision works. We also know that “it still doesn’t work” isn’t a useful reply.
If you’re new to collisions / triggers, work through some Youtube tutorials because there are very specific conditions that must be met, and those conditions are laid out very clearly in the documentation. There’s no sense in me iterating them here for you.
Isolate the triggering, verify it works with Debug.Log()
Once it works, isolate whatever you are trying to do with it, make sure it works.
In general I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.
Doing this should help you answer these types of questions:
is this code even running? which parts are running? how often does it run?
what are the values of the variables involved? Are they initialized?
Knowing this information will help you reason about the behavior you are seeing.
If you are running a mobile device you can also see the console output. Google for how.