mantling after aimed dash with new mantle system
This commit is contained in:
@@ -18,6 +18,7 @@ public partial class MantleSystem: Node3D
|
||||
private ShapeCast3D _inAirWallDetect;
|
||||
private ShapeCast3D _groundedWallDetect;
|
||||
public Curve3D MantleCurve { get; private set; }
|
||||
public Vector3 FirstMantleProfilePoint { get; private set; } = Vector3.Zero;
|
||||
|
||||
public bool IsMantlePossible { get; private set; } = false;
|
||||
public const int WallProfileCastCount = 7;
|
||||
@@ -86,6 +87,7 @@ public partial class MantleSystem: Node3D
|
||||
if (isCollisionSameAsTarget || isCollidingWithWall) continue;
|
||||
|
||||
// We have a valid collision
|
||||
if (!hasFirstProfileHit) FirstMantleProfilePoint = profilePoint;
|
||||
hasFirstProfileHit = true;
|
||||
MantleCurve.AddPoint(ToLocal(profilePoint));
|
||||
}
|
||||
@@ -93,34 +95,4 @@ public partial class MantleSystem: Node3D
|
||||
|
||||
IsMantlePossible = true;
|
||||
}
|
||||
|
||||
public Option<Vector3> FindMantle()
|
||||
{
|
||||
if (!_wallInFrontCast3D.IsColliding())
|
||||
{
|
||||
return Option<Vector3>.None;
|
||||
}
|
||||
if (_wallInFrontCast3D.GetCollisionNormal(0).Y > 0.8f)
|
||||
{
|
||||
return Option<Vector3>.None;
|
||||
}
|
||||
|
||||
var collisionPoint = _wallInFrontCast3D.GetCollisionPoint(0);
|
||||
var collisionNormal = _wallInFrontCast3D.GetCollisionNormal(0);
|
||||
return FindMantleLocationAtPoint(collisionPoint, collisionNormal);
|
||||
}
|
||||
|
||||
public Option<Vector3> FindMantleLocationAtPoint(Vector3 point, Vector3 wallNormal)
|
||||
{
|
||||
var horizontalEndLocation = point - wallNormal * MantleEndLocationDistanceFromWall;
|
||||
var shapeCastStartLocation = horizontalEndLocation + Vector3.Up * MantleHeightCastStart;
|
||||
|
||||
_mantleCast3D.SetGlobalPosition(shapeCastStartLocation);
|
||||
var targetLocation = Vector3.Down * MantleHeightCastStart + Vector3.Up * MaxStepHeight;
|
||||
_mantleCast3D.SetTargetPosition(targetLocation);
|
||||
|
||||
if (_mantleCast3D.IsColliding() && _mantleCast3D.GetCollisionNormal(0).Y >= 0.1f)
|
||||
return Option.Some(_mantleCast3D.GetCollisionPoint(0));
|
||||
return Option<Vector3>.None;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user