Godot version 4.3
I keep having the same issues with the latest part of my script. I am new and have basically zero experience in coding and am currently following a tutorial but even with it I am having issues with my animations. Here is the code I have written so far.
extends CharacterBody2D
@onready var sprite_2d: AnimatedSprite2D = $CharacterBody2D/CollisionShape2D/Sprite2D
const GRAVITY = 1000
enum State {Idle, Run }
var current_state
func _ready():
current_state = State.Idle
func _physics_process(delta):
player_falling(delta)
player_idle(delta)
player_run(delta)
move_and_slide()
player_animations()
func player_falling(delta):
if is_on_floor():
velocity.y += GRAVITY * delta
func player_idle(delta):
if is_on_floor():
current_state = State.Idle
func player_run(delta):
var direction = input.get_axis(“move_left”, “move_right”)
if direction:
velocity.x = direction + 300
else:
velocity.x = move_toward(velocity.x, 0, 300)
func player_animations():
if current_state == State.Idle:
AnimatedSprite2D.play(“idle”)
elif current_state == State.Run:
AnimatedSprite2D.play(“run”)
The main issue is this one right here /\ Func player_animations.
I keep getting errors that line 40, 45,46,47 are in some way not indented properly and then it creates a bigger mess everytime I try and fix it. Any idea on how to resolve it?