+1 vote

In the game Dread Hunger, when player climbs up onto the ship, the player moves along with ship from the perspective of the world space. When the player jumps off the ship the connection is cut off and player moves relative to the world space again not to the ship.

How can this be done with Godot? I've tired two methods but failed:

  1. Change the hierarchy on the fly: When player enters Area, remove the node from world and add it into the vehicle node.

  2. Sync the transformation (take translation as example): In physicsprocess, apply the delta translation to the player node.

Godot version 3.5.beta
in Engine by (31 points)

2 Answers

+1 vote
Best answer

Problem solved. I change the ship from staticbody to kinematicbody while the floor is still staticbody and move the ship through move and slide instead of translate

It seems it's not a good ideal to modify the translation of a rigidbody directly and staticbody is supposed to be static.

by (31 points)
0 votes

These methods should work. Why did they fail ? What happened ?

There is another method. You can use RemoteTransform node to temporarly set players transforms to those of the ship.

by (5,651 points)

Both methods result in dropping through the floor.

For debug purpose, when I press F3, the ship accelerates. The player drops through the floor when I keep pressing F3 for over seconds. At the begining everything works fine but after a while the player drops through the floor. Looking up, I found the z speed remains the same with the ship but the player drops through.

Are you using bodies for player and ship ? Are they the same body class ? ( like rigid or kinematic ) ?. Bodies transform is constantly afflicted by physics engine, it will not be as easy as copying them.
Is it supposed to behave like moving platform ?

Ship is StaticBody and player is KinematicBody. Yes it is supposed to behave like moving a platform while player can walk around on it and jump off it.

watch this youtube tutorial by Pirate Chip Games, it's probably what you are looking for.
https://www.youtube.com/watch?v=XYcC4ML5VmY
Make a 3D moving platform w/out player falling off (fps)
He uses an area and move_and_slide_with_snap with some other things, I hope that will help.

Setting stoponslope to false suppose to prevent the player from dropping. But stoponslope is false by default (which means it is false in my code), the youtuber solved the problem where it has to be true on some cases.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.