2
\$\begingroup\$

I am trying to make a moving platform in Godot (for a 2D platform game, but I suspect the issue would be similar in 3D).

Basically, both my player and my platform are KinematicBody2D, and they move via the move_and_slide() method. The documentation says:

You can use this to make moving or rotating platforms, or to make nodes push other nodes.

This seems to fit my use case. However, when the player collides with the platform, the latter will be affected. For example, if the player stands on top of the platform, it will slowly start going down. I don't want that, I want the platform to move in a fixed fashion no matter what is throw at it (and if the player stands in the path of the platform for example, the player should be pushed).

How can I solve this? I was thinking about using a StaticBody2D for the platform, but the documentation says:

A StaticBody2D is a body that is not intended to move.

So I am not sure if this is the correct solution. It seems that the move_and_slide() method has some additional parameters, such as infinite_inertia, but the documentation is not very clear to me as to what they do exactly.

\$\endgroup\$
1

1 Answer 1

1
\$\begingroup\$

Use the collision layer and mask settings. Put the player and platform on separate layers. Using the mask settings of each node, have the platform affect the player, but don't have the player affect the platform.

Are you sure you need to move-and-slide the platform? You could tween its position between two points or have it follow a path. Then it could be a RigidBody2D in kinematic mode.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .