Lou Bowlus
Lou Bowlus

Reputation: 73

Sync to physics change in godot 4

I am in the process of converting my game from godot 3 to godot 4.

Previously in godot 3 when I was using rotating platforms, my player would sink a few pixels into the rotating platforms while they were moving up, and hover a few pixels above when the platforms were moving down. I fixed this by turning on sync to physics on the moving platform(s).

Now the problem is back, and there is no sync to physics option.

I was just wondering if this was an easy fix? Or should I redo the moving platform system entirely?

Thanks.

Upvotes: 6

Views: 1507

Answers (1)

Theraot
Theraot

Reputation: 40325

The recommended Node for moving platforms in Godot 3.x was KinematicBody (2D) with motion/sync_to_physics set to true.

As you know, KinematicBody (2D) became CharacterBody (2D/3D) in Godot 4. However, it is no longer recommended for moving platforms. Instead the recommended Node for moving platforms is AnimatableBody (2D/3D) which has a sync_to_physics property which does what you want.

Thus, your fix is to change the type of the node to AnimatableBody (2D/3D) and make sure the sync_to_physics property is set to true (which is the default).

And yes, an AnimatableBody (2D/3D) is an StaticBody (2D/3D). I assure you it makes sense form the standpoint of the engine design, and also that it was a subject of endless debate (in particular if StaticBody (2D/3D) should still be called "static" if they sometimes are intended to move). But we failed to agree on something better. Please take it for what it is.

Upvotes: 7

Related Questions