Search Unity

Secondary Motion With Physics

Discussion in 'Physics' started by AcornBringer, Apr 8, 2020.

  1. AcornBringer

    AcornBringer

    Joined:
    Mar 22, 2015
    Posts:
    70
    I'm trying to attach this lantern to my character with the character physics joint so there is some secondary movement while the character walks around but I'm running into a few issues.

    My current setup is parenting the lantern to the pelvis joint of the character. Adding a ridgedbody to the pelvis joint. Adding a character joint component to the lantern and setting the pelvis joint as the connected body. The lantern also has a ridgedbody of it's own as well as a collider to interact with a collider I added to the left leg.



    The main issue is the lantern not receiving any force from the character movement. I'm pretty sure this is because the lantern is parented to the character. When I unapparent the lantern but keep the physics joint attached, I get the motion I'm looking for but I would like to keep the lantern inside the character prefab.

    The second issue I'm getting is as the character walks up against another collider, the lantern starts flipping out. I can only guess that it's because the character joint is trying to follow it's parent ridgedbody moving forward but it's actually not moving forward in space. This is also fixed by unparenting the lantern but again, I would like to keep the lantern inside the character prefab.

    --

    Am I going about this process incorrectly? Maybe someone knows a better way to set this up. I was using this method for getting the secondary movement: Unity Skeletal Ragdoll / Jiggle Bones Tutorial (Link) however this still has that issued with walking into colliders causing the lantern to go crazy and the script doesn't use rotation so I don't get any swinging as the character spins around.

    Any help would be greatly appreciated :)
     
    snoutie and Westland like this.
  2. AcornBringer

    AcornBringer

    Joined:
    Mar 22, 2015
    Posts:
    70
    I ended up just getting the player position, adding the ideal lantern position to that and setting the lantern to that position when the game runs. It is also setting the proper rigged body as it's connected body at the same time. This way I don't need to place the lantern and connect it by hand each time I have a new scene. It works great and looks nice!