fixed mantle after dash bug
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 7s
Create tag and build when new code gets to main / Export (push) Failing after 2s

This commit is contained in:
2025-09-16 10:28:41 +02:00
parent 88d20431ce
commit 7b036c5889
6 changed files with 17 additions and 43 deletions

View File

@@ -53,6 +53,7 @@ WalkSpeed = 7.5
AccelerationAir = 2.0 AccelerationAir = 2.0
DecelerationAir = 0.1 DecelerationAir = 0.1
Weight = 5.0 Weight = 5.0
MantleTime = 0.2
SimpleJumpStartVelocity = 8.0 SimpleJumpStartVelocity = 8.0
SimpleJumpHangTimeInFrames = 1 SimpleJumpHangTimeInFrames = 1
SimpleJumpGravityLesseningFactor = 2.5 SimpleJumpGravityLesseningFactor = 2.5

View File

@@ -310,7 +310,7 @@ public partial class PlayerController : CharacterBody3D
// Movement stuff // Movement stuff
// Getting universal setting from GODOT editor to be in sync // Getting universal setting from GODOT editor to be in sync
_gravity = (float)ProjectSettings.GetSetting("physics/3d/default_gravity"); _gravity = (float)ProjectSettings.GetSetting("physics/3d/default_gravity");
MantleSystem.Init(HeadSystem); MantleSystem.Init();
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth); StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
DashSystem.Init(HeadSystem, camera, TweenQueueSystem); DashSystem.Init(HeadSystem, camera, TweenQueueSystem);
WeaponSystem.Init(HeadSystem, camera); WeaponSystem.Init(HeadSystem, camera);
@@ -438,7 +438,7 @@ public partial class PlayerController : CharacterBody3D
{ {
if (CanMantle()) if (CanMantle())
{ {
MantleToLocation(MantleSystem.FindMantleInFrontOfPlayer().Unwrap()); MantleToLocation(MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y).Unwrap());
return; return;
} }
@@ -871,7 +871,7 @@ public partial class PlayerController : CharacterBody3D
{ {
// Try mantling but don't know if this is useful // Try mantling but don't know if this is useful
if (CanMantle()) if (CanMantle())
MantleToLocation(MantleSystem.FindMantleInFrontOfPlayer().Unwrap()); MantleToLocation(MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y).Unwrap());
} }
public void FinishPoweredDash() public void FinishPoweredDash()
@@ -912,7 +912,7 @@ public partial class PlayerController : CharacterBody3D
// Mantling // Mantling
public bool CanMantle() public bool CanMantle()
{ {
var mantleLocationResult = MantleSystem.FindMantleInFrontOfPlayer(); var mantleLocationResult = MantleSystem.FindMantleForHeadRotation(HeadSystem.Rotation.Y);
return mantleLocationResult.IsSome(out _); return mantleLocationResult.IsSome(out _);
} }
public void MantleToLocation(Vector3 location) public void MantleToLocation(Vector3 location)

View File

@@ -66,7 +66,7 @@ public partial class DashSystem: Node3D
_tweenQueueSystem = tweenQueueSystem; _tweenQueueSystem = tweenQueueSystem;
_mantleSystem = GetNode<MantleSystem>("MantleSystem"); _mantleSystem = GetNode<MantleSystem>("MantleSystem");
_mantleSystem.Init(this); _mantleSystem.Init();
_dashTarget = GetNode<MeshInstance3D>("DashTarget"); _dashTarget = GetNode<MeshInstance3D>("DashTarget");
_dashTarget.SetVisible(false); _dashTarget.SetVisible(false);
@@ -116,7 +116,8 @@ public partial class DashSystem: Node3D
var targetMaterial = (StandardMaterial3D) _dashTarget.GetSurfaceOverrideMaterial(0); var targetMaterial = (StandardMaterial3D) _dashTarget.GetSurfaceOverrideMaterial(0);
targetMaterial.SetAlbedo(targetColor); targetMaterial.SetAlbedo(targetColor);
_dashTarget.SetVisible(true); _dashTarget.SetVisible(true);
_dashTarget.SetGlobalPosition(PlannedLocation); var targetLocation = ShouldMantle ? PlannedMantleLocation : PlannedLocation;
_dashTarget.SetGlobalPosition(targetLocation);
} }
public void StopPreparingDash() public void StopPreparingDash()

View File

@@ -35,7 +35,7 @@ mesh = SubResource("SphereMesh_qu4wy")
surface_material_override/0 = SubResource("StandardMaterial3D_v31n3") surface_material_override/0 = SubResource("StandardMaterial3D_v31n3")
[node name="MantleSystem" parent="." instance=ExtResource("2_pff7b")] [node name="MantleSystem" parent="." instance=ExtResource("2_pff7b")]
MantleEndLocationDistanceFromWall = 0.3 MantleEndLocationDistanceFromWall = 0.25
MantleHeightCastStart = 2.0 MantleHeightCastStart = 2.0
[node name="DashIndicator" parent="." instance=ExtResource("2_tqt6i")] [node name="DashIndicator" parent="." instance=ExtResource("2_tqt6i")]

View File

@@ -5,50 +5,40 @@ namespace Movementtests.systems;
public partial class MantleSystem: Node3D public partial class MantleSystem: Node3D
{ {
[Export(PropertyHint.Range, "0,2,0.1,suffix:m,or_greater")] [Export(PropertyHint.Range, "0,2,0.01,suffix:m,or_greater")]
public float MantleEndLocationDistanceFromWall { get; set; } = 1f; public float MantleEndLocationDistanceFromWall { get; set; } = 1f;
[Export(PropertyHint.Range, "0,10,0.1,suffix:m,or_greater")] [Export(PropertyHint.Range, "0,10,0.1,suffix:m,or_greater")]
public float MantleHeightCastStart { get; set; } = 2f; public float MantleHeightCastStart { get; set; } = 2f;
[Export(PropertyHint.Range, "0,10,0.01,suffix:m,or_greater")] [Export(PropertyHint.Range, "0,10,0.01,suffix:m,or_greater")]
public float MaxStepHeight = 0.5f; public float MaxStepHeight = 0.5f;
private Node3D _head;
private ShapeCast3D _wallInFrontCast3D; private ShapeCast3D _wallInFrontCast3D;
private ShapeCast3D _mantleCast3D; private ShapeCast3D _mantleCast3D;
private RayCast3D _mantleCheckCast3D; private RayCast3D _mantleCheckCast3D;
private Option<Vector3> _mantleLocation; private Option<Vector3> _mantleLocation;
public void Init(Node3D head) public void Init()
{ {
_head = head;
_wallInFrontCast3D = GetNode<ShapeCast3D>("WallInFrontCast3D"); _wallInFrontCast3D = GetNode<ShapeCast3D>("WallInFrontCast3D");
_mantleCast3D = GetNode<ShapeCast3D>("MantleCast3D"); _mantleCast3D = GetNode<ShapeCast3D>("MantleCast3D");
} }
public override void _PhysicsProcess(double delta) public Option<Vector3> FindMantleForHeadRotation(float rotation)
{ {
base._PhysicsProcess(delta);
_wallInFrontCast3D.SetRotation(new Vector3( _wallInFrontCast3D.SetRotation(new Vector3(
_wallInFrontCast3D.Rotation.X, _wallInFrontCast3D.Rotation.X,
_head.Rotation.Y, rotation,
_wallInFrontCast3D.Rotation.Z)); _wallInFrontCast3D.Rotation.Z));
if (!_wallInFrontCast3D.IsColliding()) if (!_wallInFrontCast3D.IsColliding())
{ {
_mantleLocation = Option<Vector3>.None; return Option<Vector3>.None;
return;
} }
var collisionPoint = _wallInFrontCast3D.GetCollisionPoint(0); var collisionPoint = _wallInFrontCast3D.GetCollisionPoint(0);
var collisionNormal = _wallInFrontCast3D.GetCollisionNormal(0); var collisionNormal = _wallInFrontCast3D.GetCollisionNormal(0);
_mantleLocation = FindMantleLocationAtPoint(collisionPoint, collisionNormal); return FindMantleLocationAtPoint(collisionPoint, collisionNormal);
}
public Option<Vector3> FindMantleInFrontOfPlayer()
{
return _mantleLocation;
} }
public Option<Vector3> FindMantleLocationAtPoint(Vector3 point, Vector3 wallNormal) public Option<Vector3> FindMantleLocationAtPoint(Vector3 point, Vector3 wallNormal)
@@ -60,7 +50,7 @@ public partial class MantleSystem: Node3D
var targetLocation = Vector3.Down * MantleHeightCastStart + Vector3.Up * MaxStepHeight; var targetLocation = Vector3.Down * MantleHeightCastStart + Vector3.Up * MaxStepHeight;
_mantleCast3D.SetTargetPosition(targetLocation); _mantleCast3D.SetTargetPosition(targetLocation);
if (_mantleCast3D.IsColliding() && _mantleCast3D.GetCollisionNormal(0).Y > 0.9f) if (_mantleCast3D.IsColliding() && _mantleCast3D.GetCollisionNormal(0).Y >= 0.1f)
return Option.Some(_mantleCast3D.GetCollisionPoint(0)); return Option.Some(_mantleCast3D.GetCollisionPoint(0));
return Option<Vector3>.None; return Option<Vector3>.None;
} }

View File

@@ -218,22 +218,4 @@ public partial class MoveSystem : Node3D
var jumpVelocity = jumpForce * effectiveJumpDirection * boost; var jumpVelocity = jumpForce * effectiveJumpDirection * boost;
_parent.Velocity = currentHorizontalVelocity + jumpVelocity; _parent.Velocity = currentHorizontalVelocity + jumpVelocity;
} }
public bool CanMantle()
{
var mantleLocationResult = _mantleSystem.FindMantleInFrontOfPlayer();
return mantleLocationResult.IsSome(out _);
}
public Option<Tween> Mantle()
{
var mantleLocationResult = _mantleSystem.FindMantleInFrontOfPlayer();
if (mantleLocationResult.IsSome(out var mantleLocation))
{
var duration = 0.1f * mantleLocation.DistanceTo(_parent.Position);
var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(mantleLocation, duration));
return tween.Some();
}
return Option<Tween>.None;
}
} }