Is it possible to completely disable y axis movement?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ggez

Imagine, like the original doom game. There’s no y axis (up and down / vertical) movement. Is it possible to disable y axis movement on kinematicbody?

Here’s what I tried:

func _ready():
set_axis_lock(PhysicsServer.BODY_AXIS_ANGULAR_Y & PhysicsServer.BODY_AXIS_LINEAR_Y, true)

However, it can still move on the y axis.

Does just move_lock_y = true work?

DDoop | 2020-07-16 20:29

No. The kinematic body can still go up. By up, i mean, e.g. walking on a slope (where the player should actually stop, instead of sliding up).

ggez | 2020-07-16 20:36

:bust_in_silhouette: Reply From: Calinou

Axis lock isn’t implemented yet in KinematicBody: set_axis_lock not working on KinematicBody 3D · Issue #25798 · godotengine/godot · GitHub

As a workaround, call self.transform.origin.z = 0 every frame.

I made my first pull request on the docs to clarify this.

DDoop | 2020-07-18 00:21