Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Bounciness 0 on both objects, bullet still bouncing

Discussion in 'Physics' started by Erenquin, Nov 13, 2020.

  1. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Hello,
    as the title implies, simple as that.

    Both the projectile and the wall have bouniness 0, yet the projectile bounces.
    This is the physics material I use for both:
    upload_2020-11-13_11-19-54.png

    If you have any idea why this is happening I would be grateful :)
     

    Attached Files:

  2. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,065
    I don't really know but have you tried it with continuous collision detection ? (don't forget that with CCD your dynamic object collider must be one of the primitives)
     
  3. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Thanks for the reply.
    The collision works well and is detected correctly.

    My problem is that after the collision the projectile still bounces.
    What I could find is that this could not be related to bounciness actually but to the physics reacting to the collision and applying force that result in the wall repelling the projectile.

    A confirmation would be nice :)

    What I do now is deactivate the projectile at collision (which involves additional coding to handle stuff, like collision effect).
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,065
    I'm asking because if it's not CCD there might be a lot of penetration and the projectile might be ejected from inside the body with greater force. With CCD the penetration should be lower. If it is the case than you know what is going on, if not than you must search further.
     
  5. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Thanks for the explanation.
    I checked and yes, I set the projectile in "Interpolate" and "Continuous dynamic".
    The wall does not have a rigidbody.
     
  6. wootrop

    wootrop

    Joined:
    Mar 24, 2020
    Posts:
    15
    You can try to set the Bounce Combine to Minimum (if you haven't already tried); but anyway in theory must work also with your actual setup because both objects are without bounciness... but give it a try.

    Also can you pause the game and show frame by frame what is happening near the wall?
     
  7. patrykszylindev

    patrykszylindev

    Joined:
    Oct 28, 2019
    Posts:
    23
    What you describing, I think I'm experiencing in this thread that I'm about to link. Do you know how to prevent an object being "ejected"?

    here's a link to illustrate what I mean https://forum.unity.com/threads/pla...r-is-enabled-inside-another-collider.1008796/
     
  8. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,065
    I think this bounciness you experience is to extreme.
    With such a low speed as this character collider you should not penetrate very deep.
    Are you sure physics materials are set properly on both colliders ?
     
  9. patrykszylindev

    patrykszylindev

    Joined:
    Oct 28, 2019
    Posts:
    23
    Are you referring to my issue? I am able to get into the collider (penetrate) because I'm disabling the collider during player's motion.
     
  10. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,065
    If you disable the collider than naturally you will have deep penetration and then when enabled inside a body you will bounce with a strong velocity.
     
  11. patrykszylindev

    patrykszylindev

    Joined:
    Oct 28, 2019
    Posts:
    23
    You're not quite right.

    Apparently, you can prevent that by setting RigidBody's velocity to 0 before re-enabling collider, that solved my issue.
     
  12. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    Thanks all for the replies.
    In the end what I do is simply disable the ammo before destroying it.
    That works for me:
    Code (CSharp):
    1. GameObject effect = Instantiate(CollisionEffect, transform.position, originalOrientation);
    2. Destroy(effect, CollisionEffectTime);
    3. gameObject.SetActive(false);
    4. Destroy(gameObject, CollisionEffectTime);