Player doesnt stick to a moving platporm

Godot Version

v4.3.stable.arch_linux

Question

I’m making a simple platformer game in which the main mechanic is a “Van” (StaticBody) that acts as a “moving platform” that starts moving automatically when the player climbs over the roof (Like “The Dolphin The Dolphin” from Dadish 3)

func _physics_process(delta: float) -> void:
   match Current_state
   	States.MOVING:
   		print("VAN MOVING")
   		global_position.x += SPEED * delta
func _on_player_detector_body_entered(body: Node2D) -> void:
	Current_state = States.MOVING

My problem is that when the van starts moving, the player doesn’t move with it, so it slides through the roof of the van like this:

Is there any way to fix my issue, thanks in advance

PD: Sorry for my bad English, I apologize for any misspelt word or confusing sentence, and also, if you need more information, feel free to ask

Because as the node name implies, this node is not to be used in a case that have moviment, use the AnimatableBody2D node instead.

I can’t use an AnimatableBody2D because of the special behaviour of the platform, it doesn’t stop

I didn’t get why wouldn’t work, could you explain more your situation?

I’m trying to search for a solution that is more flexible to a wide range of level sizes (so I don’t have to edit the animations for each level)

Sorry man! I found out that I didn’t need an AnimationPlayer to move an AnimatableBody2D, I didn’t want to use one because I thought I had to move it through animation, sorry for any inconveniences, god bless you

2 Likes