Hey I am trying to make a 2D platformer with sprite animations, but I keep getting this error "Invalid get index 'flip'(on base: 'AnimatedSprite2D')". This is my code, does anyone have a idea of what im doing wrong?

extends CharacterBody2D

const SPEED = 300.0
const JUMP_VELOCITY = -400.0

var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
@onready var anim = get_node("AnimationPlayer")

func _physics_process(delta):
if not is_on_floor():
velocity.y += gravity * delta

if Input.is_action_just_pressed("ui_accept") and is_on_floor():
	velocity.y = JUMP_VELOCITY
	anim.play("Jump")

var direction = Input.get_axis("ui_left", "ui_right")
print(direction)
if direction == -1:
	get_node("AnimatedSprite2D").flip.h = true
elif direction == 1:
	get_node("AnimatedSprite2D").flip.h = false
	
if direction:
	velocity.x = direction * SPEED
	if velocity.y == 0:
		anim.play("Run")
	
	velocity.x = move_toward(velocity.x, 0, SPEED)
	if velocity.y == 0:
		anim.play("Idle")
		
	if velocity.y > 0:
		anim.play("Fall")

move_and_slide()
  • xyz replied to this.
  • Irnes The error message means that there is no flip property in AnimatedSprite2D. Whenever you get such an error it is advisable to check the class reference and see if maybe you misspelled the property. So if you look at the reference for AnimatedSprite2D you'll see that there is indeed no flip property. However, there is flip_v and flip_h.

    Irnes The error message means that there is no flip property in AnimatedSprite2D. Whenever you get such an error it is advisable to check the class reference and see if maybe you misspelled the property. So if you look at the reference for AnimatedSprite2D you'll see that there is indeed no flip property. However, there is flip_v and flip_h.

      xyz Thank you so much I was pulling my hair at this for the past 2 days and now I can finally make some progress.