mantle system fix amazing
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 22s
Create tag and build when new code gets to main / Export (push) Successful in 8m19s

This commit is contained in:
2025-12-19 18:59:34 +01:00
parent 2e2df4ff50
commit b792e8721c
8 changed files with 156 additions and 76 deletions

View File

@@ -14,17 +14,15 @@ public partial class MantleSystem: Node3D
private ShapeCast3D _wallInFrontCast3D;
private ShapeCast3D _mantleCast3D;
private ShapeCast3D _inAirWallDetect;
private ShapeCast3D _groundedWallDetect;
public Curve3D MantleCurve { get; private set; }
public bool IsMantlePossible { get; private set; } = false;
public int NumberOfValidPofiles { get; private set; } = -1;
public const int WallProfileCastCount = 7;
private ShapeCast3D[] _wallProfileShapecasts = new ShapeCast3D[WallProfileCastCount];
public Vector3[] WallProfilePositions { get; private set; } = new Vector3[WallProfileCastCount];
public Vector3[] WallProfileNormals { get; private set; } = new Vector3[WallProfileCastCount];
public void Init()
{
@@ -55,21 +53,15 @@ public partial class MantleSystem: Node3D
SetCastsEnabled(isColliding);
// Reset state
NumberOfValidPofiles = -1;
IsMantlePossible = false;
if (!isColliding)
{
return;
}
if (!isColliding) return;
// Check if collide with wall
var collisionNormal = isGrounded ? _groundedWallDetect.GetCollisionNormal(0) : _inAirWallDetect.GetCollisionNormal(0);
if (collisionNormal.Y > 0.8f)
{
return;
}
NumberOfValidPofiles = 0;
if (collisionNormal.Y > 0.9f) return;
MantleCurve = new Curve3D();
MantleCurve.AddPoint(Vector3.Zero);
var hasFirstProfileHit = false;
foreach (var wallProfileShapecast in _wallProfileShapecasts)
{
@@ -81,9 +73,7 @@ public partial class MantleSystem: Node3D
// Got to the other side of the wall, we stop there
if (!wallProfileShapecast.IsColliding())
{
WallProfilePositions[NumberOfValidPofiles] = globalTargetPosition;
WallProfileNormals[NumberOfValidPofiles] = Vector3.Zero;
NumberOfValidPofiles += 1;
MantleCurve.AddPoint(ToLocal(globalTargetPosition));
break;
}
@@ -92,16 +82,16 @@ public partial class MantleSystem: Node3D
// Check if we collided parallel to a wall
var isCollisionSameAsTarget = globalTargetPosition.IsEqualApprox(profilePoint);
var isCollidingWithWall = profileNormal.Y < 0.9f;
var isCollidingWithWall = profileNormal.Y < 0.1f;
if (isCollisionSameAsTarget || isCollidingWithWall) continue;
// We have a valid collision
WallProfilePositions[NumberOfValidPofiles] = profilePoint;
WallProfileNormals[NumberOfValidPofiles] = profileNormal;
hasFirstProfileHit = true;
NumberOfValidPofiles += 1;
MantleCurve.AddPoint(ToLocal(profilePoint));
}
IsMantlePossible = NumberOfValidPofiles > 0; // Should always be true
if (MantleCurve.PointCount == 1) return;
IsMantlePossible = true;
}
public Option<Vector3> FindMantle()