this is the code
the node looks like this :
KinematicBody(script)
-AnimatedSprite = "playersprite"
* -Collisionshape2D
---
error: E 0:00:02.462 set_animation: There is no animation with name 'idle'.
<C++ Error> Condition "frames == __null" is true.
<C++ Source> scene/2d/animated_sprite.cpp:651 @ set_animation()
<Stack Trace> :0 @ void Godot.NativeCalls.godot_icall_1_53(IntPtr , IntPtr , System.String )()
AnimatedSprite.cs:222 @ void Godot.AnimatedSprite.SetAnimation(System.String )()
AnimatedSprite.cs:47 @ void Godot.AnimatedSprite.set_Animation(System.String )()
player.cs:35 @ void player.getInput()()
player.cs:41 @ void player._PhysicsProcess(Single )()
public class player : KinematicBody2D
{
const float GRAVITY = 20;
const float speed = 70;
const float jumpspeed = -120;
private Vector2 Up = new Vector2(0, -1);
private Vector2 motion = new Vector2();
private AnimatedSprite player_Animation;
public override void _Ready(){
player_Animation = GetNode<AnimatedSprite>("playersprite");
}
public void getInput()
{
var right = Input.IsActionPressed("ui_right");
var left = Input.IsActionPressed("ui_left");
var jump = Input.IsActionPressed("ui_select");
if (IsOnFloor() && jump)
motion.y = jumpspeed;
if (right){
motion.x += speed;
player_Animation.FlipH = false;
player_Animation.Play("run");
}
else if (left){
motion.x -= speed;
player_Animation.FlipH = true;
player_Animation.Play("run");
}
else{
motion.x = 0;
player_Animation.Play("idle");
}
}
public override void _PhysicsProcess(float delta)
{
getInput();
motion.y += GRAVITY * delta;
motion = MoveAndSlide(motion, Up);
}
}