So I am trying to just rotate the camera/player 90 degrees (dungeon crawler style). I got it working but it would only turn once and get stuck in a loop. I found the -0 in the transform and have tried a few things but no luck
extends KinematicBody
var rotation_speed = .50
var targettransform
var rotation_lerp = 0
func _ready():
targettransform = self.transform.basis
func _process(delta):
if self.transform.basis != targettransform:
rotate_player(delta)
#not transform.basis.is_equal_approx(targettransform, 0.0001):
if self.transform.basis == targettransform:
rotation_lerp = 0
get_input()
print(transform.basis)
print(targettransform)
func rotate_player(delta):
if rotation_lerp < 1:
rotation_lerp += delta * rotation_speed
elif rotation_lerp > 1:
rotation_lerp = 1
transform.basis = transform.basis.slerp(targettransform , rotation_lerp).orthonormalized()
func get_input():
if Input.is_action_just_pressed("turn_left"):
print("left")
targettransform = self.transform.basis.rotated(Vector3(0,1,0),1.5707963).orthonormalized()
print (self.transform.basis.rotated(Vector3(0,1,0),1.5708))
if Input.is_action_just_pressed("turn_right"):
print("right")
targettransform = self.transform.basis.rotated(Vector3(0,1,0),-1.5707963).orthonormalized()
print (self.transform.basis.rotated(Vector3(0,1,0),-1.5708))
if Input.is_action_just_pressed("Test_button"):
print (transform.basis)
print (targettransform)
Then I tried 0.0001 to 1 for the isequalapprox
func _process(delta):
if not self.transform.basis.is_equal_approx(targettransform, 1):
rotate_player(delta)
if transform.basis.is_equal_approx(targettransform, 1):
rotation_lerp = 0
get_input()