31 lines
649 B
C#
31 lines
649 B
C#
using Godot;
|
|
|
|
namespace DRPGActionGame.Player.States;
|
|
|
|
public partial class MoveState : State {
|
|
private Player2 player;
|
|
public override void _Ready() {
|
|
player = GetParent<Player2>();
|
|
player.Playback.Travel("move");
|
|
}
|
|
|
|
public override void _PhysicsProcess(double delta) {
|
|
Vector3 velocity = player.Velocity;
|
|
|
|
if (player.Direction != Vector3.Zero)
|
|
{
|
|
player.ChangeState("move");
|
|
velocity.X = player.Direction.X * Player2.SPEED;
|
|
velocity.Z = player.Direction.Z * Player2.SPEED;
|
|
}
|
|
else {
|
|
player.ChangeState("idle");
|
|
}
|
|
|
|
player.Velocity = velocity;
|
|
}
|
|
|
|
public override void Exit() {
|
|
GD.Print("Exit Move State");
|
|
}
|
|
} |