Added new animations

This commit is contained in:
qwsdcvghyu89
2026-06-11 14:43:51 +10:00
parent 3ccf193a7c
commit 6ee79020ef
8 changed files with 184 additions and 8 deletions
+20 -6
View File
@@ -78,16 +78,30 @@ public partial class PlayerPhysicsController : CharacterBody2D {
public override void _Process(double delta) {
var grounded = this.IsOnFloor();
var absvel = new Vector2(Mathf.Abs(Velocity.X), Mathf.Abs(Velocity.Y));
Sprite.FlipH = Velocity.X < 0;
if (grounded && absvel.X > 0) {
Sprite.Play("walk", absvel.X switch {
var xAxis = Input.GetAxis("move_left", "move_right");
Sprite.FlipH = xAxis < 0;
if (grounded && absvel.X > 0.1) {
Sprite.Animation = "walk";
Sprite.SpeedScale = absvel.X switch {
< 10 => 1,
< 150 => 2,
< 300 => 4,
_ => 1
});
} else if (grounded && absvel.X < epsilon && absvel.Y < epsilon) {
Sprite.Play("idle");
};
} else {
Sprite.SpeedScale = 1;
}
if (grounded && absvel.X < 0.1) {
Sprite.Animation = "idle";
}
if (!grounded && Velocity.Y > 0.1) {
Sprite.Animation = "fall";
}
if (!grounded && Velocity.Y < 0.1) {
Sprite.Animation = "jump";
}
}