DungeonRPG/Scripts/Characters/Player3D/Player3DMoveState.cs

36 lines
981 B
C#

using Godot;
using System;
using DungeonRPG.Scripts.General;
public partial class Player3DMoveState : PlayerState3D
{
[Export(PropertyHint.Range, "0, 20,0.1")] private float speed = 5;
public override void _PhysicsProcess(double delta)
{
if (characterNode.Direction == Vector2.Zero)
{
characterNode.StateMachine.SwitchState<Player3DIdleState>();
return;
}
characterNode.Velocity = new Vector3(characterNode.Direction.X, 0, characterNode.Direction.Y);
characterNode.Velocity *= speed;
characterNode.MoveAndSlide();
}
public override void _Input(InputEvent @event)
{
if (Input.IsActionJustPressed(GameConstants.INPUT_DASH))
{
characterNode.StateMachine.SwitchState<Player3DDashState>();
}
}
protected override void EnterState()
{
characterNode.AnimationPlayer.Play("walk", customBlend: 0.1f);
}
}