need to fix the angle interpolation but its a start #8

Merged
ysandler merged 2 commits from initial-rotation-addition into main 2025-03-10 19:23:22 -05:00
4 changed files with 104 additions and 7 deletions

93
dem8633.tmp Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,6 @@ extends CharacterBody2D
const SPEED = 350.0
func _physics_process(delta: float) -> void:
global.emit_signal("playerPosition",self.global_position)
movement()
@ -14,6 +13,11 @@ func animation():
func movement():
var vertical = Input.get_axis("up","down")
var horizontal = Input.get_axis("left","right")
var rotVector = Vector2(vertical*-1,horizontal).normalized()
#self.rotation = rotVector.angle()
if rotVector != Vector2(0,0):
var rotationTween = get_tree().create_tween()
rotationTween.tween_property(self,"global_rotation",rotVector.angle(),0.1)
if is_equal_approx(abs(vertical),1.0) and is_equal_approx(abs(horizontal),1.0):
velocity.y = SPEED*vertical/2
velocity.x = SPEED*horizontal/2
@ -21,4 +25,4 @@ func movement():
velocity.y = SPEED * vertical
velocity.x = SPEED * horizontal
move_and_slide()
$"../Camera2D/Label".text = (str(self.global_position))
$"../Camera2D/Label".text = (str(vertical)+" "+str(horizontal) + "vector:"+str(rotVector))