- Home /
OnCollision Not working can someone explain
hey im trying to write a script for a destruction type thing
but i need to attach a rigidbody then a object is hit by a ball (this object has a mech collider)
Im firing a ball from the player it has a rigidbody attached(obviously)
but when it hits an object with my script attached that has
onCollisionenter and then attaches a rigidbody and also does other stuff
but on collision enter doesnt get called
also i tryed adding a rigidbody on the object that the ball is hitting and set it to kinematic and onCollision got called (couldnt attach rigidbody cause it already had one)
but for what im doing i CANT have a rigidbody with kinematic checked for the object that the ball is hitting.
SO IF someone could explain whats happening that would be great becasue i though this should have worked (i have been using unity for quite a while so im not a complete noob. well i thought i wasnt)
sorry for any spelling mistakes i wrote this quickly
~Scott
Answer by meat5000 · May 29, 2014 at 11:52 AM
Perhaps attach a child object with a kinematic rigidbody and use that for the collisions
i have a thing i call a beam in my script this beam acts as a support these beams are then connected with joints(and have rigidbodys) to make a shape of a building. so if you destroy the bottom one the building collapses its to calculate the structural integrity of the building. later what i call rubble in my script are children of this beam. now the idea was for these beams be not colliding with rubble which they do(not collider that is)and if the rubble gets hit by a rigidbody it would call onCollisionEnter which would calculate if the bit of rubble will break off. if it did break off it would be unparented and a rigidbody would be added to it. now the problem is that if i dont have a rigidbody oncollisionenter doesn't get called when my rigidbody sphere hits it with the correct amount of force to break it off. and if i have a rigidbody attached to the rubble with kinematic set to true(so it doesnt move) it can detect the collision and then i can set is$$anonymous$$inematic to false which is all good. but if this beam is standing up and it has rubble all around it and it falls over the rubble just clips through the ground and doesnt effect the beam at all. its like the rubble isnt even there.
pictures the white cube is the beam and are individual objects childed to the beam(rubble)

One is where the rubble doesnt have rigidbodys attached and i will attach them if the rubble breaks off. but they dont register OnCollisionEnter
and the other is where the rubble is clipping through bthe ground and doesnt effect the beam at all but accept collisions
thanks for reading
if you have any ideas on how to fix this please reply or even any other methods of doing what im trying to do would be great
thanks ~Scott

Your answer
Follow this Question
Related Questions
Collision Only being detected on one of the objects involved in the collision - C# 0 Answers
Anyway to make my object not fall through the floor without convex? 0 Answers
what object hit me? easy rigidbody question 1 Answer
Fast moving object not detect collision 3 Answers
Why I've a gap between meshcolliders? 0 Answers