Note that there are some explanatory texts on larger screens.

plurals
  1. POUnity collision bounces off, but no OnCollisionEnter
    primarykey
    data
    text
    <p>I have a problem with Unity collision system. </p> <p>I'm trying to add some 3d objects(rocks) to my scene <b>with mesh collider</b>(convex mesh collider ticked), but <b>no rigidbody</b>. I have a bullet prefab <b>with rigidbody and sphere collider</b>. I attached a script to the bullet prefab, that <b>OnCollisionEnter</b> it should destroy the bullet prefab and play an explosion particle. </p> <p>Now the problem is that when I shoot the bullet towards the 3d object (rock) it <b>bounces off instead of exploding</b>( aka no OnCollisionEnter called). With other colliders like box, capsule or terrain collider it works just fine. </p> <p>I tried to <b>add a rigidbody</b> to it, after which it starts working, <b>OnCollisionEnter is called</b> and the bullet explodes, <b>but the problem with this is that I can move the 3d object with physics which I shouldn't be able to</b>. To solve this i <b>tried to constraint in the inspector the position and rotation</b>, which I thought solved my problem, because the <b>bullet explodes on contact</b> and the <b>3d object won't move</b>, but now my other problem is that <b>I can walk through the object</b>... </p> <p><b>Any 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?</b> </p> <p><b>Edit1</b>: Forgot to mention that I already <b>tried IsKinematic</b> same rule applies, bullet bounces off, but no OnCollisionEnter called. </p> <p><b>Edit2, somewhat solution:</b> I ended up <b>duplicating</b> 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. Even though this seems to work, for me it seems a little bit over kill and probably gives me an overhead, is there any better solution for it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload