Godot 4.3
Hello! I’m working on my animation with every limb of my player sprite being able to move. But when I load it in (even when clicking play on start and putting the animation to start on the ready function) it doesn’t show the sprite. How do I fix this?
CODE:
extends CharacterBody2D
var SPEED = 450.0
@export var JUMP_VELOCITY: float = -600.0
var is_double_jump = false
func _ready():
add_to_group("Player")
$"Different Anim".play("Idle_RIGHT")
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if is_on_floor():
is_double_jump = true
if Input.is_action_just_pressed("jump"):
if is_on_floor():
velocity.y = JUMP_VELOCITY
elif is_double_jump:
velocity.y = JUMP_VELOCITY
is_double_jump = false
if Input.is_action_just_pressed("run"):
SPEED = 670
if Input.is_action_just_released("run"):
SPEED = 450
var direction := Input.get_axis("left", "right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, 22)
move_and_slide()
update_facing_direction()
update_facing_direction()
func update_facing_direction():
if Input.is_action_just_pressed("left"):
if Vector2.AXIS_X == -1:
$"Different Anim".play("Idle_LEFT")
print("IDLE-LEFT")
if Input.is_action_just_pressed("right"):
if Vector2.AXIS_X == 1:
$"Different Anim".play("Idle_RIGHT")
print("IDLE-RIGHT")