0 votes

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.

asked Jul 16 in Engine by ggez (17 points)

Does just move_lock_y = true work?

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).

1 Answer

+1 vote
Best answer

Axis lock isn't implemented yet in KinematicBody: https://github.com/godotengine/godot/issues/25798

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

answered Jul 17 by Calinou (6,520 points)
selected Jul 17 by ggez

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

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.