Is possible to change angular_velocity if it is disabled in Axis Lock (RigiBody3D)?

Godot Version



This is my problem. I have RigidBody3D Character, everything work for movements and camera but problem is that character change is rotation when i walk on non-flat terrain (procedurally generated terrain (mountains)).

When i lock Angular Y of rigid body in Axis Lock, character work perfectly but i can not move camera (left-right cam movement is character y rotation).

Collision shape = CapsuleShape with radius 0.3m and height 1.8m.

Possible sulution

  • Lock Angular Y in Axis Lock and force change angular_velocity.y in code (I don’t know how to do this).

  • Unlock Angular Y in Axis Lock and somehow stabilize the character to stop auto-rotating y on terrain.


Here is my code (sorry bcs it is on Bosnian language):

# trenutna_brzina = current speed
# mis = mouse
# senzitiviti = sensitivity
# lerp_brzina = lerp speed

# This is for movement.
func _integrate_forces(_state):
	var input_direkcija = Input.get_vector("A", "D", "W", "S")
	var brzina_usporavanja = lerp_brzina if not na_ledu else brzina_leda
	direkcija = lerp(direkcija, (transform.basis * Vector3(input_direkcija.x, 0, input_direkcija.y)).normalized(),_delta*brzina_usporavanja)
	if Input.is_action_pressed("SHIFT"):
		trenutna_brzina = sprint
		trenutna_brzina = brzina
	var velocity = linear_velocity
	velocity.x = direkcija.x * trenutna_brzina
	velocity.z = direkcija.z * trenutna_brzina
	if Input.is_action_just_pressed("SPACE") and is_on_floor():
		velocity.y = skok_snaga
		velocity.y -= gravitacija * _delta
	linear_velocity = velocity

 	#This code don't work when Axis Lock AngularY is locked. Only work when it is unlocked.
	angular_velocity.y = lerp(angular_velocity.y, deg_to_rad(-mis.pos.x *senzitiviti* 1.95), _delta * lerp_brzina*4)

# glava - is head.
# mis - is mouse.

# This is for camera.
# This code is fine, it work for look up and down for "head". But i look left-right on character rotation.y (angular_velocity.y)
func _process(delta):
	glava.rotation_degrees.x -= mis.pos.y * (senzitiviti*2) * delta;
	glava.rotation_degrees.x = clamp(glava.rotation_degrees.x, -88, 88)
	mis.pos = Vector2.ZERO


This is my terrain:

if someone can help me please do that because i lost my 5 days to fix this and i have no idea how to do it. im mentally destroyed guys