Godot 4.2.2
I keep getting this error
while trying to make animations for my FNAF game it didn’t happen before but now it does!
Invalid set index 'flip_h' (on base: 'null instance') with value type of 'bool'
Can somone help me please?
My code so far:
extends CharacterBody2D
const SPEED = 200
const FAST_SPEED = 400
var current_speed = SPEED
var animation_player : AnimationPlayer
const NORMAL_ANIMATION_SPEED = 1.0
const FAST_ANIMATION_SPEED = 2.0
var animation_speed = NORMAL_ANIMATION_SPEED
func _ready():
var animation_player = $AnimationPlayer
func _physics_process(delta):
var motion = Vector2.ZERO
if Input.is_action_pressed("d"):
$%prite.flip_h = false
motion.x += 1
$AnimationPlayer.play("Run")
elif Input.is_action_pressed("a"):
%Sprite.flip_h = true
motion.x -= 1
$AnimationPlayer.play("Run")
elif Input.is_action_pressed("s"):
motion.y += 1
$AnimationPlayer.play("Run")
elif Input.is_action_pressed("w"):
motion.y -= 1
$AnimationPlayer.play("Run")
else:
$AnimationPlayer.play("Idle")
motion = motion.normalized()
if Input.is_key_pressed(KEY_SHIFT):
current_speed = FAST_SPEED
animation_speed = FAST_ANIMATION_SPEED
else:
current_speed = SPEED
animation_speed = NORMAL_ANIMATION_SPEED
position += motion * current_speed * delta