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

How do I make my player move properly with a moving vehicle?

Discussion in 'Physics' started by Nikuras, Aug 15, 2022.

  1. Nikuras

    Nikuras

    Joined:
    Aug 23, 2015
    Posts:
    4
    I am trying to make a sailing game, but I can't seem to move the player with the boat properly. My current setup is that I have a trigger on the boat, and when the player enters the trigger, I parent the player to the boat. But what ends up happening once the player is on the boat is that the player only follows along partially, and slowly slides off the boat as it speeds up.

    Both the boat and the player have rigidbodies and are moved around by applying forces. The issue does not appear if I move the boat around manually in the scene view during runtime. I tried using a position constraint as well but that didn't seem to work at all. Would really appreciate it if someone has any thoughts for how to fix it!
     
  2. knobblez

    knobblez

    Joined:
    Nov 26, 2017
    Posts:
    223
    I have a boat and a player, both with rigidbodies. I use:
    Code (CSharp):
    1.             playermovement.gameObject.transform.parent = boat.transform;

    I use transform.position += speed though. I bet it has something to do with those forces. You could try disabling the player's rigidbody while in the driver seat.
     
  3. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    Not sure if this helps, but i made a video lol

     
  4. NarutoU21

    NarutoU21

    Joined:
    Sep 27, 2020
    Posts:
    12
    Hey @Nikuras i think making the player rigidbody static after entering on the boat will help you. If not then kindly share a clip or something for better understanding will totally help us.
     
  5. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    592
    if you are playing an animation on player character, make sure the root motion is not applied (in older unity versions this was not causing a problem), even if it is only in-place.
     
  6. knobblez

    knobblez

    Joined:
    Nov 26, 2017
    Posts:
    223
    Does your player RB have more drag than your boat RB? I don't know if that is the problem, just trying to think of what might cause problems