ufpix.blogg.se

Bounce when touch collision on mesh unity
Bounce when touch collision on mesh unity





bounce when touch collision on mesh unity

Notes: Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached. The Collision class contains information, for example, about contact points and impact velocity.

bounce when touch collision on mesh unity

To solve this i tried to constraint in the inspector the position and rotation, which I thought solved my problem, because the bullet explodes on contact and the 3d object won't move, but now my other problem is that I can walk through the object.Īny idea how to solve my problem? So that I would have a 3d object with meshcollider calling OnCollisionEnter on contact with a sphere collider, but not letting me pass trough it?Įdit1: Forgot to mention that I already tried IsKinematic same rule applies, bullet bounces off, but no OnCollisionEnter called.Įdit2, somewhat solution: I ended up duplicating the object, removing mesh renderer from second one scaling it a little bit and removing Gravity and IsKinematic, this way that layer triggers OnCollisionEnter and my bullet explodes, the original is let at IsKinematic witch don't let me go trough the object and because the other layer is a little bit bigger the bullet can't bounce off. In contrast to OnTriggerEnter, OnCollisionEnter is passed the Collision class and not a Collider. I tried to add a rigidbody to it, after which it starts working, OnCollisionEnter is called and the bullet explodes, but the problem with this is that I can move the 3d object with physics which I shouldn't be able to. With other colliders like box, capsule or terrain collider it works just fine.

bounce when touch collision on mesh unity

Now the problem is that when I shoot the bullet towards the 3d object (rock) it bounces off instead of exploding( aka no OnCollisionEnter called). I attached a script to the bullet prefab, that OnCollisionEnter it should destroy the bullet prefab and play an explosion particle. I have a bullet prefab with rigidbody and sphere collider. I'm trying to add some 3d objects(rocks) to my scene with mesh collider(convex mesh collider ticked), but no rigidbody. I have a problem with Unity collision system.







Bounce when touch collision on mesh unity