so im very new to godot and just started to make my first game
i implemented a double jump system
then i wanted the character to face the mouse cursor whenever it was in the air
so did the following
const SPEED = 300.0
const JUMP_VELOCITY = -700.0
const NUM_EXTRA_JUMPS = 1
var extra_jumps : int = NUM_EXTRA_JUMPS
@onready var animation_player: AnimationPlayer = $AnimationPlayer
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity += get_gravity() * delta
look_at(get_global_mouse_position())
rotation += 90
else:
rotation = 0
if Input.is_action_just_pressed("jump"):
if is_on_floor():
velocity.y = JUMP_VELOCITY
animation_player.play("jump")
extra_jumps = NUM_EXTRA_JUMPS
elif extra_jumps > 0:
velocity.y = JUMP_VELOCITY
animation_player.play("jump")
extra_jumps -= 1
var direction := Input.get_axis("move_left", "move_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()```
but whenever i try to play the game and hit the floor at any other angle except straight down
it starts jittering between the mouse direction and straight up
for context i want it to point straight up when its on ground
and follow mouse direction when in air
i cant figure out what is wrong here i would be grateful if someone could point me in the right direction