Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Vibrating player collisions

Discussion in 'Physics' started by Bannanaking3, Aug 22, 2023.

  1. Bannanaking3

    Bannanaking3

    Joined:
    Jun 21, 2022
    Posts:
    109
    I have a problem where when my player stands on top of a dynamic rigid body object the player vibrates nauseatingly, making the camera shake. is this a known problem? how do I fix this?
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,630
    Nope, not a known/usual problem. Any physical object on top of another physical object shouldn't vibrate, that's just how you stack stuff. Otherwise mostly everything in any game would vibrate.

    Now, if your player is not a dynamic rigidbody, then things can go haywire on a variety of ways depending on how you're dealing with it.
     
  3. Bannanaking3

    Bannanaking3

    Joined:
    Jun 21, 2022
    Posts:
    109
    The player and the object are both dynamic, and the object the player is standing on is on a static collider with no rigid body
     
  4. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,630
    So both the player and the object are dynamic, but the object is static? this doesn't make any sense whatsoever. How can an object be both static and dynamic simultaneously?

    If you create a dynamic (aka non-kinematic) rigidbody and place it on top of a static collider in Unity, it won't shake. It only takes a few seconds for you to test this.

    My advice would be to work out differences between your setup and this basic one, and go over them one by one to identify which one is causing the problem.
     
  5. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,834
    CharacterController standing on top of a moving object, whether Rigidbody or not, can be pretty bouncy. Some other kinematic controllers share this issue. It's a pain in the rear. When you detect such a condition (your isGrounded code finds a moving object), you can make the CharacterController a child of the moving object and still move around. Alternatively you can try to keep up with the motion of the moving object and move the CC along with it, but you may find yourself a frame behind especially where the moving body is changing speeds.

    And yeah, once you see it in your own code, you WILL see it in otherwise polished games. Even famous AAA games.
     
    arkano22 likes this.
  6. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,630
    Yes, CharacterControllers on top of moving objects can be pretty shaky.

    However, OP so far has said that:
    and
    So no idea if it's standing on a moving kinematic rigidbody, a static kinematic rigidbody, a dynamic rigidbody, or a simple collider with no rigidbody.
     
  7. Bannanaking3

    Bannanaking3

    Joined:
    Jun 21, 2022
    Posts:
    109

    the player is on a dynamic rigid body which is on a static collider. in other words, standing on a box which is resting on a floor