gd: setup a target and a simple dash to target
This commit is contained in:
@ -34,6 +34,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
private bool _canDoubleJump = true;
|
||||
private bool _movementEnabled = true;
|
||||
private Vector3 _dashLocation = Vector3.Zero;
|
||||
|
||||
private float _currentSpeed;
|
||||
|
||||
@ -138,9 +139,30 @@ public partial class PlayerController : CharacterBody3D
|
||||
_movementEnabled = true;
|
||||
}
|
||||
|
||||
private void TweenToLocation(Vector3 location, float duration)
|
||||
{
|
||||
Tween tween = GetTree().CreateTween();
|
||||
var callback = new Callable(this, MethodName.EnableMovement);
|
||||
|
||||
tween.TweenProperty(this, "position", location, duration);
|
||||
tween.TweenCallback(callback);
|
||||
|
||||
DisableMovement();
|
||||
tween.Play();
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
var dashLocation = DashSystem.PrepareDash().Unwrap();
|
||||
if (Input.IsActionPressed("aim_dash"))
|
||||
{
|
||||
_dashLocation = DashSystem.PrepareDash().Unwrap();
|
||||
}
|
||||
|
||||
if (Input.IsActionJustReleased("aim_dash"))
|
||||
{
|
||||
DashSystem.Dash();
|
||||
TweenToLocation(_dashLocation, 0.1f);
|
||||
}
|
||||
|
||||
var mantleLocationResult = MantleSystem.CheckWallInFront();
|
||||
if (isOnFloorCustom())
|
||||
@ -169,15 +191,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
if (mantleLocationResult.IsOk(out var mantleLocation))
|
||||
{
|
||||
Tween tween = GetTree().CreateTween();
|
||||
var duration = 0.1f * mantleLocation.DistanceTo(Position);
|
||||
var callback = new Callable(this, MethodName.EnableMovement);
|
||||
|
||||
tween.TweenProperty(this, "position", mantleLocation, duration);
|
||||
tween.TweenCallback(callback);
|
||||
|
||||
DisableMovement();
|
||||
tween.Play();
|
||||
TweenToLocation(mantleLocation, duration);
|
||||
}
|
||||
else if (isOnFloorCustom())
|
||||
{
|
||||
|
Reference in New Issue
Block a user