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
DecelerationAir = 0.1
Weight = 5.0
MantleTime = 0.2
SimpleJumpStartVelocity = 8.0
SimpleJumpHangTimeInFrames = 1
SimpleJumpGravityLesseningFactor = 2.5

View File

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

View File

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

View File

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

View File

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

View File

@@ -218,22 +218,4 @@ public partial class MoveSystem : Node3D
var jumpVelocity = jumpForce * effectiveJumpDirection * boost;
_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;
}
}