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.

in Engine by (82 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.

by (12,453 points)
selected by

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.