mantle system fix amazing
This commit is contained in:
@@ -65,7 +65,7 @@ WalkSpeed = 7.5
|
||||
AccelerationAir = 2.0
|
||||
DecelerationAir = 0.1
|
||||
Weight = 5.0
|
||||
MantleTime = 0.3
|
||||
MantleTime = 0.2
|
||||
CoyoteTime = 0.3
|
||||
SimpleJumpStartVelocity = 8.0
|
||||
SimpleJumpHangTimeInFrames = 1
|
||||
@@ -502,45 +502,45 @@ delay_in_seconds = "0.0"
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("SimpleJump")
|
||||
|
||||
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Mantling")
|
||||
event = &"mantle"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="SimpleJump" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnMegajump" type="Node" parent="StateChart/Root/Movement/Jump/SimpleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../MegaJump")
|
||||
event = &"megajump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnJumpEnded" type="Node" parent="StateChart/Root/Movement/Jump/SimpleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/DoubleJumpEnabled")
|
||||
event = &"jump_ended"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnMegajump" type="Node" parent="StateChart/Root/Movement/Jump/DoubleJump"]
|
||||
[node name="OnMegajump" type="Node" parent="StateChart/Root/Movement/Jump/SimpleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../MegaJump")
|
||||
event = &"megajump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJumpEnded" type="Node" parent="StateChart/Root/Movement/Jump/DoubleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/Falling")
|
||||
event = &"jump_ended"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnMegajump" type="Node" parent="StateChart/Root/Movement/Jump/DoubleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../MegaJump")
|
||||
event = &"megajump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="MegaJump" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJumpEnded" type="Node" parent="StateChart/Root/Movement/Jump/MegaJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/Falling")
|
||||
event = &"jump_ended"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Dashing" type="Node" parent="StateChart/Root/Movement"]
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("Dash")
|
||||
@@ -707,6 +707,12 @@ to = NodePath("../../Airborne/Reset")
|
||||
event = &"start_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/OnWall"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Mantling")
|
||||
event = &"mantle"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="HuggingCoyoteEnabled" type="Node" parent="StateChart/Root/Movement/OnWall"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
|
||||
@@ -81,6 +81,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
[ExportGroup("Mantle")]
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float MantleTime { get; set; } = 0.1f;
|
||||
[Export]
|
||||
public PackedScene MantlePath { get; set; } = GD.Load<PackedScene>("res://scenes/path/Path.tscn");
|
||||
|
||||
// Jump
|
||||
[ExportGroup("Jump")]
|
||||
@@ -186,6 +188,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
private bool _canDash = true;
|
||||
private bool _shouldMantleOnDashEnded;
|
||||
|
||||
private Vector3 _wallHugStartLocation = Vector3.Zero;
|
||||
private Vector3 _wallHugStartNormal = Vector3.Zero;
|
||||
private Vector3 _wallHugStartProjectedVelocity = Vector3.Zero;
|
||||
private Vector3 _currentWallContactPoint = Vector3.Zero;
|
||||
|
||||
private StateChart _playerState;
|
||||
|
||||
private StateChartState _aiming;
|
||||
@@ -197,7 +204,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
private StateChartState _grounded;
|
||||
private StateChartState _airborne;
|
||||
private StateChartState _coyoteEnabled;
|
||||
private StateChartState _doubleJumpEnabled;
|
||||
// private StateChartState _doubleJumpEnabled;
|
||||
private StateChartState _simpleJump;
|
||||
private StateChartState _doubleJump;
|
||||
private StateChartState _megaJump;
|
||||
@@ -221,6 +228,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
private float _playerHeight;
|
||||
private float _playerRadius;
|
||||
private bool _isJumpInputPressed = false;
|
||||
|
||||
private float _lookSensitivityMultiplier = 1.0f;
|
||||
private float _mouseSensitivityMultiplier = 1.0f;
|
||||
@@ -294,7 +302,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
_grounded = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded"));
|
||||
_airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne"));
|
||||
_coyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/CoyoteEnabled"));
|
||||
_doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled"));
|
||||
// _doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled"));
|
||||
_simpleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/SimpleJump"));
|
||||
_doubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/DoubleJump"));
|
||||
_megaJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/MegaJump"));
|
||||
@@ -351,6 +359,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
_grounded.StateEntered += OnGrounded;
|
||||
_grounded.StatePhysicsProcessing += HandleGrounded;
|
||||
_airborne.StatePhysicsProcessing += HandleAirborne;
|
||||
_onWall.StatePhysicsProcessing += HandleOnWall;
|
||||
|
||||
_coyoteEnabled.StateEntered += StartCoyoteTime;
|
||||
_timeScaleAimInAirTimer.Timeout += ResetTimeScale;
|
||||
@@ -454,20 +463,29 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
_canDash = true;
|
||||
}
|
||||
|
||||
public bool IsTryingToMantle()
|
||||
{
|
||||
return MantleSystem.IsMantlePossible && GetMoveInput().Z < -0.5f && _isJumpInputPressed;
|
||||
}
|
||||
|
||||
public void HandleGrounded(float delta)
|
||||
{
|
||||
MoveOnGround(delta);
|
||||
// if (IsTryingToMantle()) _playerState.SendEvent("mantle");
|
||||
if (!isOnFloorCustom())
|
||||
_playerState.SendEvent("start_falling");
|
||||
}
|
||||
|
||||
public void HandleAirborne(float delta)
|
||||
{
|
||||
|
||||
MoveInAir(delta);
|
||||
if (isOnFloorCustom())
|
||||
_playerState.SendEvent("grounded");
|
||||
|
||||
if (IsTryingToMantle()) _playerState.SendEvent("mantle");
|
||||
|
||||
if (!WallHugSystem.IsWallHugging())
|
||||
return;
|
||||
|
||||
@@ -497,6 +515,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleOnWall(float delta)
|
||||
{
|
||||
if (IsTryingToMantle()) _playerState.SendEvent("mantle");
|
||||
}
|
||||
|
||||
public void OnWallHuggingStarted()
|
||||
{
|
||||
GetTree().CreateTimer(CoyoteTime).Timeout += CoyoteExpired;
|
||||
@@ -507,11 +530,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
GetTree().CreateTimer(CoyoteTime).Timeout += CoyoteExpired;
|
||||
}
|
||||
|
||||
private Vector3 _wallHugStartLocation = Vector3.Zero;
|
||||
private Vector3 _wallHugStartNormal = Vector3.Zero;
|
||||
private Vector3 _wallHugStartProjectedVelocity = Vector3.Zero;
|
||||
private Vector3 _currentWallContactPoint = Vector3.Zero;
|
||||
|
||||
public void OnWallDetected()
|
||||
{
|
||||
FinishPoweredDash();
|
||||
@@ -591,10 +609,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
Velocity = Vector3.Zero;
|
||||
GlobalPosition = _wallHugStartLocation;
|
||||
}
|
||||
|
||||
|
||||
// Jump
|
||||
public void OnInputJumpStarted()
|
||||
{
|
||||
_isJumpInputPressed = true;
|
||||
if (MantleSystem.IsMantlePossible)
|
||||
{
|
||||
_playerState.SendEvent("mantle");
|
||||
@@ -620,6 +639,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void OnInputJumpEnded()
|
||||
{
|
||||
_isJumpInputPressed = false;
|
||||
_playerState.SendEvent("jump_ended");
|
||||
}
|
||||
|
||||
@@ -725,38 +745,48 @@ public partial class PlayerController : CharacterBody3D
|
||||
z: velocity.Y);
|
||||
}
|
||||
|
||||
private Path _mantlePath;
|
||||
public void OnMantleStarted()
|
||||
{
|
||||
HeadSystem.OnMantle();
|
||||
|
||||
_mantlePath = MantlePath.Instantiate() as Path;
|
||||
if (_mantlePath == null)
|
||||
{
|
||||
GD.PrintErr("Failed to instantiate MantlePath");
|
||||
return;
|
||||
};
|
||||
|
||||
_preMantleVelocity = Velocity;
|
||||
GetTree().GetRoot().AddChild(_mantlePath);
|
||||
_mantlePath.Setup(MantleSystem.GlobalTransform, MantleSystem.MantleCurve);
|
||||
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.SetTrans(Tween.TransitionType.Cubic);
|
||||
tween.SetTrans(Tween.TransitionType.Linear);
|
||||
tween.SetEase(Tween.EaseType.InOut);
|
||||
var inbetweenDuration = MantleTime / MantleSystem.NumberOfValidPofiles;
|
||||
for (int i = 0; i < MantleSystem.NumberOfValidPofiles; i += 1)
|
||||
{
|
||||
var position = MantleSystem.WallProfilePositions[i];
|
||||
tween.TweenProperty(this, "global_position", position, inbetweenDuration);
|
||||
}
|
||||
|
||||
tween.TweenProperty(_mantlePath.PathFollow, "progress_ratio", 1, MantleTime);
|
||||
tween.Finished += MantleFinished;
|
||||
}
|
||||
|
||||
public void HandleMantling(float delta)
|
||||
{
|
||||
|
||||
GlobalPosition = _mantlePath.Target.GlobalPosition;
|
||||
}
|
||||
|
||||
public void MantleFinished()
|
||||
{
|
||||
Velocity = _preMantleVelocity;
|
||||
_mantlePath.Teardown();
|
||||
var direction = GetInputGlobalHDirection();
|
||||
if (direction.Length() > 0)
|
||||
{
|
||||
SetVelocity(direction * SimpleDashStrength);
|
||||
}
|
||||
_playerState.SendEvent("grounded");
|
||||
}
|
||||
|
||||
public void HandleJump(float delta, float gravityFactor, int hangFrames)
|
||||
{
|
||||
if (IsTryingToMantle()) _playerState.SendEvent("mantle");
|
||||
|
||||
// Update horizontal velocity
|
||||
var horizontalVelocity = ComputeHVelocityAir(delta);
|
||||
Velocity = new Vector3(horizontalVelocity.X, Velocity.Y, horizontalVelocity.Z);
|
||||
@@ -986,9 +1016,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void RecoverWeapon()
|
||||
{
|
||||
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
||||
AddChild(WeaponRoot);
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
RecoverChildNode(WeaponRoot);
|
||||
WeaponSystem.ResetWeapon();
|
||||
}
|
||||
|
||||
@@ -1051,14 +1079,25 @@ public partial class PlayerController : CharacterBody3D
|
||||
WeaponRoot.CallDeferred(Node3D.MethodName.SetGlobalPosition, TutorialWeaponTarget.GlobalPosition);
|
||||
WeaponSystem.CallDeferred(WeaponSystem.MethodName.PlaceWeaponForTutorial, TutorialWeaponTarget.GlobalPosition);
|
||||
}
|
||||
|
||||
public void RemoveChildNode(Node3D node)
|
||||
{
|
||||
RemoveChild(node);
|
||||
GetTree().GetRoot().AddChild(node);
|
||||
node.SetGlobalPosition(GlobalPosition);
|
||||
}
|
||||
|
||||
public void RecoverChildNode(Node3D node)
|
||||
{
|
||||
GetTree().GetRoot().RemoveChild(node);
|
||||
AddChild(node);
|
||||
node.SetGlobalPosition(GlobalPosition);
|
||||
}
|
||||
|
||||
public void ThrowWeapon()
|
||||
{
|
||||
_playerState.SendEvent("cancel_aim");
|
||||
|
||||
RemoveChild(WeaponRoot);
|
||||
GetTree().GetRoot().AddChild(WeaponRoot);
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
RemoveChildNode(WeaponRoot);
|
||||
|
||||
var weaponTargetLocation = DashSystem.HasHit ? DashSystem.CollisionPoint : DashSystem.PlannedLocation;
|
||||
WeaponSystem.ThrowWeapon(
|
||||
|
||||
Reference in New Issue
Block a user