god dayum wall hugging on point man
This commit is contained in:
@ -4,6 +4,9 @@ namespace Movementtests.systems;
|
||||
|
||||
public partial class DashSystem: Node3D
|
||||
{
|
||||
public record DashLocation(bool HasHit, Vector3 TargetLocation);
|
||||
|
||||
|
||||
[Export(PropertyHint.Range, "0,0.2,0.01,or_greater")]
|
||||
public float DashSpeed { get; set; } = 0.1f;
|
||||
[Export(PropertyHint.Range, "0,1000,1,or_greater")]
|
||||
@ -60,14 +63,14 @@ public partial class DashSystem: Node3D
|
||||
_dashIndicatorAnim = GetNode<AnimationPlayer>("DashIndicator/AnimationPlayer");
|
||||
}
|
||||
|
||||
private void ComputeDashLocation()
|
||||
private DashLocation ComputeDashLocation()
|
||||
{
|
||||
TargetLocation = _dashCast3D.ToGlobal(_dashCast3D.TargetPosition);
|
||||
HasHit = _dashCast3D.IsColliding();
|
||||
if (!HasHit)
|
||||
|
||||
var targetLocation = _dashCast3D.ToGlobal(_dashCast3D.TargetPosition);
|
||||
var hasHit = _dashCast3D.IsColliding();
|
||||
if (!hasHit)
|
||||
{
|
||||
PlannedPlayerLocation = TargetLocation;
|
||||
return;
|
||||
return new DashLocation(false, targetLocation);
|
||||
}
|
||||
|
||||
CollisionPoint = _dashCast3D.GetCollisionPoint(0);
|
||||
@ -80,12 +83,23 @@ public partial class DashSystem: Node3D
|
||||
// Pushes the point down when dashing to under a platform so head doesn't clip
|
||||
var maxPushDownDistance = 0.9f;
|
||||
var correctionProportion = (float) Mathf.Remap(CollisionNormal.Y, -0.5, -1, 0, 1);
|
||||
var proportion = (float) Mathf.Remap(_dashCast3D.GlobalRotation.X, 0, 1.57, 0, 1);
|
||||
PlannedPlayerLocation = locationAlongPath
|
||||
+ CollisionNormal
|
||||
* maxPushDownDistance
|
||||
* Mathf.Clamp(proportion, 0, 1)
|
||||
* Mathf.Clamp(correctionProportion, 0, 1);
|
||||
var proportion = (float)Mathf.Remap(_dashCast3D.GlobalRotation.X, 0, 1.57, 0, 1);
|
||||
var finalLocation = locationAlongPath
|
||||
+ CollisionNormal
|
||||
* maxPushDownDistance
|
||||
* Mathf.Clamp(proportion, 0, 1)
|
||||
* Mathf.Clamp(correctionProportion, 0, 1);
|
||||
|
||||
return new DashLocation(true, finalLocation);
|
||||
}
|
||||
|
||||
public DashLocation GetDashLocationInDirection(Vector3 direction)
|
||||
{
|
||||
var angle = Mathf.Atan2(direction.X, direction.Z);
|
||||
GD.Print(angle);
|
||||
var rotation = _head.Rotation.Y + angle*2.0f;
|
||||
_dashCast3D.SetRotation(new Vector3(0, rotation, 0));
|
||||
return ComputeDashLocation();
|
||||
}
|
||||
|
||||
public void PrepareDash()
|
||||
@ -97,7 +111,7 @@ public partial class DashSystem: Node3D
|
||||
_head.Rotation.Y,
|
||||
_camera.Rotation.Z));
|
||||
|
||||
ComputeDashLocation();
|
||||
(HasHit, PlannedPlayerLocation) = ComputeDashLocation();
|
||||
|
||||
ShouldMantle = false;
|
||||
var mantleLocation = Vector3.Zero;
|
||||
|
Reference in New Issue
Block a user