diff --git a/doc/classes/KinematicBody.xml b/doc/classes/KinematicBody.xml
index 464369d197c..bc671e04eb9 100644
--- a/doc/classes/KinematicBody.xml
+++ b/doc/classes/KinematicBody.xml
@@ -144,6 +144,15 @@
+
+ Lock the body's X axis movement.
+
+
+ Lock the body's Y axis movement.
+
+
+ Lock the body's Z axis movement.
+
Extra margin used for collision recovery in motion functions (see [method move_and_collide], [method move_and_slide], [method move_and_slide_with_snap]).
If the body is at least this close to another body, it will consider them to be colliding and will be pushed away before performing the actual motion.
@@ -154,13 +163,13 @@
If [code]true[/code], the body's movement will be synchronized to the physics frame. This is useful when animating movement via [AnimationPlayer], for example on moving platforms. Do [b]not[/b] use together with [method move_and_slide] or [method move_and_collide] functions.
- Lock the body's X axis movement.
+ Lock the body's X axis movement. Deprecated alias for [member axis_lock_motion_x].
- Lock the body's Y axis movement.
+ Lock the body's Y axis movement. Deprecated alias for [member axis_lock_motion_y].
- Lock the body's Z axis movement.
+ Lock the body's Z axis movement. Deprecated alias for [member axis_lock_motion_z].
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 035928e5ec1..51f5f35fb22 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1294,6 +1294,11 @@ bool KinematicBody::separate_raycast_shapes(bool p_infinite_inertia, Collision &
}
void KinematicBody::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool p_lock) {
+ if (p_lock) {
+ locked_axis |= p_axis;
+ } else {
+ locked_axis &= (~p_axis);
+ }
PhysicsServer::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock);
}
@@ -1434,6 +1439,10 @@ void KinematicBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("_direct_state_changed"), &KinematicBody::_direct_state_changed);
+ ADD_GROUP("Axis Lock", "axis_lock_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_motion_x"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_motion_y"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_motion_z"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Z);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_x", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_X);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_y", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Y);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_z", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Z);
@@ -1463,6 +1472,7 @@ KinematicBody::~KinematicBody() {
}
}
}
+
///////////////////////////////////////
Vector3 KinematicCollision::get_position() const {