#animations refusing to work?

1 messages · Page 1 of 1 (latest)

olive gale
#

i'm currently using https://docs.godotengine.org/en/stable/getting_started/first_2d_game/03.coding_the_player.html, and i'm at

    $AnimatedSprite2D.animation = "walk"
    $AnimatedSprite2D.flip_v = false
    # See the note below about the following boolean assignment.
    $AnimatedSprite2D.flip_h = velocity.x < 0
elif velocity.y != 0:
    $AnimatedSprite2D.animation = "up"
    $AnimatedSprite2D.flip_v = velocity.y > 0 ``` 
but here's the thing, it presents the attached image with errors.
it's worked fine up until then, here are my sprites
#

wait why did that image post twice whoops

#

@export var speed = 400 # How fast the player will move (pixels/sec).
var screen_size # Size of the game window.
func _ready():
    screen_size = get_viewport_rect().size
func _process(delta):
    var velocity = Vector2.ZERO # The player's movement vector.
    if Input.is_action_pressed("move_right"):
        velocity.x += 1
    if Input.is_action_pressed("move_left"):
        velocity.x -= 1
    if Input.is_action_pressed("move_down"):
        velocity.y += 1
    if Input.is_action_pressed("move_up"):
        velocity.y -= 1

    if velocity.length() > 0:
        velocity = velocity.normalized() * speed
        $AnimatedSprite2D.play()
    else:
        $AnimatedSprite2D.stop()
    position += velocity * delta
    position = position.clamp(Vector2.ZERO, screen_size)
    if velocity.x != 0:
    $AnimatedSprite2D.animation = "walk"
    $AnimatedSprite2D.flip_v = false
    # See the note below about the following boolean assignment.
    $AnimatedSprite2D.flip_h = velocity.x < 0
elif velocity.y != 0:
    $AnimatedSprite2D.animation = "up"
    $AnimatedSprite2D.flip_v = velocity.y > 0awddawsdsasd ```
(GDScript, not C#)
stable basin
#

you need to fix the identations in that code

#

in gdscript script identation is very important for the code to work properly