Rigid body local position

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

I want to be able to direct my object(rigid body) with “WSAD” keys but when camera follows it always go to spesific direction rather than transforming according to my current position.

I have seen many example with kinetic body but no use for rigid body

const FlOOR_NORMAL := Vector3.UP
func look_follow(state, current_transform, target_position):
    var up_dir = Vector3(0, 1, 0)
    var cur_dir = current_transform.basis.xform(Vector3(0, 0, 1))
    var target_dir = (target_position - current_transform.origin).normalized()
    var rotation_angle = acos(cur_dir.x) - acos(target_dir.x)

    state.set_angular_velocity(up_dir * (rotation_angle / state.get_step()))

func _integrate_forces(state):
	var target_position = $".".get_global_transform().origin
	look_follow(state, get_global_transform(), target_position)

	if Input.is_action_pressed("ui_space"):
		apply_central_impulse(Vector3.UP * 1.5)
	if Input.is_action_pressed("ui_w"):
		apply_impulse(cur_dir, Vector3(2, 0,0))
#		apply_central_impulse(Vector3.FORWARD * 1.5)
	if Input.is_action_pressed("ui_d"):
		apply_central_impulse(Vector3.RIGHT * 1.5)
	if Input.is_action_pressed("ui_a"):
		apply_central_impulse(Vector3.LEFT * 1.5)