How do I get objects to detect collisions?
I am creating an endless runner. I need to be able to know when the player has hit the spikes. I've tried OnCollisionEnter, OnTriggerEnter, turning off and on "is trigger", I've messed around with the tags and layers, I've tried putting the detection script on both the player and the spikes and nothing seems to work. I've seen plenty of tutorials where they'll just throw down one of those and it works which makes want to know what's so different about mine? The only thing I think I can really do is just upload my game in it's entirety to so that you can see everything. I'll do my best to clear anything up.
If an object that has both a non-kinematic RigidBody and a convex, non-trigger collider is stopped by another objects which has a non-trigger collider, and they are both in layers that are set to register collisions between them (Physics settings), then you know that collisions are registered. Are all of the conditions listed above true for your setup?
the player has a non-kinematic rigidbody
I'm not sure what a convex is
The player has a non trigger collider
the spikes have non trigger colliders
I'm not sure how to edit the layer physics, I found the "edit layers" inspector, but I couldn't find anything about it's physics, I set them both to the default layer in the hopes that that would be automatically set for me.
$$anonymous$$eshColliders can be set to convex. For the meaning of the world, check Wikipedia.
Edit -> Project Settings -> Physics
I also suggest you learn to use the Unity Scripting API and Unity User $$anonymous$$anual, lots of useful information in there, especially for beginners.
Answer by JA_555 · Oct 01, 2015 at 08:26 PM
If you still haven't solved it, I guess there is always the option of doing it by distance. For example, you could attach a script to the spikes that say, if the players distance is less than one, add damage.
Answer by syscrusher · Oct 02, 2015 at 05:42 AM
Check the colliders overview page in the Unity manual. There is a table with very detailed information on what collisions are and are not reported. Your situation is collisions, no triggers (there are two tables).
Your answer
Follow this Question
Related Questions
How to show an object when collided with 0 Answers
Is it possible to control prevent/enable colisions based on the value of a variable. 2 Answers
Jitter with Tilemap Collider's but no Jitter on standard Box Collider 1 Answer
Can't make the character and ground collide (2d). 3 Answers
[c sharp] why isn't my player dying when it touches the truck? 1 Answer