Search Unity

Character on ship

Discussion in 'Physics' started by lennartkueppers, Nov 2, 2018.

  1. lennartkueppers

    lennartkueppers

    Joined:
    May 23, 2018
    Posts:
    20
    Hey,

    I have a test game in which you can steer a ship on a fully animated ocean with buoyancy and so on...everything works fine.
    Now I just want to add a First Person character to my game which of Course can walk on the ship, steer it etc...also here everything works fine...the character detects the steering Wheel, can enter ship-mode and so on but I cant get the Walking on the ship right...My character should behave like a normal human while he is Walking on the ship, but right now he is left behind the ship, or sliding around due to the buoyancy or something else. I already tried out almost everything xD
    A solution would be to create a static duplicate of the ship but i dont want that...Best would be to use Physics to achieve that...Any ideas? Btw. it is not important whether to use a Rigidbody Character or not...
    Thanks in advance and sorry for my english :D
     
  2. BoogieD

    BoogieD

    Joined:
    Jun 8, 2016
    Posts:
    236
    Is the character a child of the ship? I'm not sure if is as simple as that though.
     
    lennartkueppers likes this.
  3. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    2 thing you can do:

    1) like @BoogieD said, make the player a child of the ship, this should work effortlessly if you don't a rigidbody player

    2) if you do have a rigidbody player, the way to go is to keep the ship and player in place and move the ocean around them to give the impression the player and ship is moving through the ocean.
     
    lennartkueppers likes this.
  4. lennartkueppers

    lennartkueppers

    Joined:
    May 23, 2018
    Posts:
    20
    First thanks for the replies:)
    I have already tried to child the Player to the ship, but the character wasnt able to walk, or when he was able he still did not follow the ship (Rotation and velocity)...

    And the idea with the moving ocean...I want to create a multiplayer game, and this seems like a very unnatural solution^^

    By the way when you just child a Player to the ship, doesnt he follow the ship 1:1 ? I mean when you are Standing on a ship you are automatically balancing to Keep looking Forward...
    Hope that was clear xD

    And when somebody knows or has a "tech demo" for this Problem I would be very happy if you let me know :)

    Thanks
     
  5. BoogieD

    BoogieD

    Joined:
    Jun 8, 2016
    Posts:
    236
    Just some ideas to explore but I'm not sure.
    If the character is a child of the ship it should just follow the movement of the ship when standing still. Right?
    You may have to look at you walking script and see if any of the code is reliant on world coordinates and change that to the parent (the ship) instead.
    If you have rigidbody ship perhaps the ships position is not relevant until LateUpdate for the above to work.
    If you have a also have rigidbody character perhaps you need to add the ship velocity to the characters velocity.
     
    lennartkueppers likes this.