added a small dash when leaving a wall run organically
This commit is contained in:
@@ -762,6 +762,12 @@ to = NodePath("../../Running")
|
||||
event = &"coyote_expired"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnLeaveWall" type="Node" parent="StateChart/Root/Movement/OnWall/RunningCoyoteEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/CoyoteEnabled")
|
||||
event = &"start_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Running" type="Node" parent="StateChart/Root/Movement/OnWall"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
@@ -771,6 +777,12 @@ to = NodePath("../../../Jump/SimpleJump")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnLeaveWall" type="Node" parent="StateChart/Root/Movement/OnWall/Running"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/CoyoteEnabled")
|
||||
event = &"start_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
||||
[connection signal="input_aim_down" from="InputController" to="." method="OnInputAimDown"]
|
||||
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
||||
|
||||
@@ -225,6 +225,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
private Transition _onJumpFromWall2;
|
||||
private Transition _onJumpFromWall3;
|
||||
private Transition _onMegajumpFromWall;
|
||||
private Transition _onLeaveWallFromRunCoyote;
|
||||
private Transition _onLeaveWallFromRun;
|
||||
|
||||
private float _playerHeight;
|
||||
private float _playerRadius;
|
||||
@@ -319,6 +321,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
_onWallHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hanging"));
|
||||
_onWallRunning = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Running"));
|
||||
_onWallRunningCoyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/RunningCoyoteEnabled"));
|
||||
_onLeaveWallFromRun = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/Running/OnLeaveWall"));
|
||||
_onLeaveWallFromRunCoyote = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/RunningCoyoteEnabled/OnLeaveWall"));
|
||||
// State timers
|
||||
_powerCooldownTimer = GetNode<Timer>("PowerCooldown");
|
||||
_timeScaleAimInAirTimer = GetNode<Timer>("TimeScaleAimInAir");
|
||||
@@ -411,6 +415,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
_onJumpFromWall2.Taken += OnJumpFromWall;
|
||||
_onJumpFromWall3.Taken += OnJumpFromWall;
|
||||
_onMegajumpFromWall.Taken += OnMegajumpFromWall;
|
||||
_onLeaveWallFromRun.Taken += OnLeaveWallFromRun;
|
||||
_onLeaveWallFromRunCoyote.Taken += OnLeaveWallFromRun;
|
||||
}
|
||||
|
||||
public void SetAllowedInputsAll()
|
||||
@@ -538,6 +544,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
return;
|
||||
|
||||
var newWallNormal = WallHugSystem.WallHugNormal.UnwrapOr(Vector3.Up);
|
||||
if (newWallNormal.AngleTo(_wallHugStartNormal) > Mathf.Pi/4) return;
|
||||
_wallHugStartNormal = newWallNormal;
|
||||
}
|
||||
|
||||
@@ -555,6 +562,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
public void OnWallStopped()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnLeaveWallFromRun()
|
||||
{
|
||||
SimpleDashInDirection(Velocity.Normalized());
|
||||
}
|
||||
|
||||
public void HandleWallHugging(float delta)
|
||||
{
|
||||
@@ -749,6 +761,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
private bool _customMantle;
|
||||
private Transform3D _customMantleStartTransform;
|
||||
private Curve3D _customMantleCurve;
|
||||
private Vector3 _mantleStartPosition;
|
||||
public void OnMantleStarted()
|
||||
{
|
||||
HeadSystem.OnMantle();
|
||||
@@ -764,6 +777,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
var curve = _customMantle ? _customMantleCurve : MantleSystem.MantleCurve;
|
||||
GetTree().GetRoot().AddChild(_mantlePath);
|
||||
_mantlePath.Setup(transform, curve);
|
||||
_mantleStartPosition = GlobalPosition;
|
||||
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.SetTrans(Tween.TransitionType.Linear);
|
||||
@@ -776,19 +790,27 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
GlobalPosition = _mantlePath.Target.GlobalPosition;
|
||||
}
|
||||
|
||||
public void SimpleDashInDirection(Vector3 direction)
|
||||
{
|
||||
SetVelocity(direction * SimpleDashStrength);
|
||||
}
|
||||
|
||||
public void SimpleDash()
|
||||
{
|
||||
SetVelocity(GetInputGlobalHDirection() * SimpleDashStrength);
|
||||
SimpleDashInDirection(GetInputGlobalHDirection());
|
||||
}
|
||||
|
||||
public void MantleFinished()
|
||||
{
|
||||
_mantlePath.Teardown();
|
||||
var direction = GetMoveInput();
|
||||
if (direction.Length() > 0)
|
||||
var isThereMovementInput = GetMoveInput().Length() > 0;
|
||||
if (isThereMovementInput)
|
||||
{
|
||||
SimpleDash();
|
||||
// If there's a movement input on Mantle, we dash in the direction the mantle took place
|
||||
var positionDifference = GlobalPosition - _mantleStartPosition;
|
||||
var directionHorizontal = new Vector3(positionDifference.X, 0, positionDifference.Z);
|
||||
SimpleDashInDirection(directionHorizontal.Normalized());
|
||||
}
|
||||
|
||||
_customMantle = false;
|
||||
|
||||
Reference in New Issue
Block a user