Skip to content

Commit

Permalink
camera dest pos tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelFB committed Feb 5, 2024
1 parent 372ee50 commit ca5fcae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Source/Actors/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ private enum Events { Land };
private record struct CameraOverride(Vec3 Position, Vec3 LookAt);
private CameraOverride? cameraOverride = null;
private Vec3 cameraOriginPos;
private Vec3 cameraDestinationPos;

private float tCoyote;
private float coyoteZ;
Expand Down Expand Up @@ -474,7 +475,7 @@ public override void LateUpdate()
GetCameraTarget(out lookAt, out cameraPos, out _);
}

World.CameraDestPos = cameraPos;
cameraDestinationPos = cameraPos;
World.Camera.Position += (cameraPos - World.Camera.Position) * (1 - MathF.Pow(0.01f, Time.Delta));
World.Camera.LookAt = lookAt;

Expand Down Expand Up @@ -608,7 +609,7 @@ private Vec2 RelativeMoveInput
// instead of World.Camera.Position. This allows the player to keep going
// in the same direction (not slightly shifted left/right), even though
// the camera always tries to be "ahead" of the player.
var cameraForward = (World.Camera.LookAt - World.CameraDestPos).Normalized().XY();
var cameraForward = (World.Camera.LookAt - cameraDestinationPos).Normalized().XY();

if (cameraForward.X == 0 && cameraForward.Y == 0)
forward = targetFacing;
Expand Down
3 changes: 0 additions & 3 deletions Source/Scenes/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ public enum EntryReasons { Entered, Returned, Respawned }
private float strawbCounterEase = 0;
private int strawbCounterWas;

// the position that the camera follows
public Vector3 CameraDestPos;

private bool IsInEndingArea => Get<Player>() is {} player && Overlaps<EndingArea>(player.Position);
private bool IsPauseEnabled
{
Expand Down

0 comments on commit ca5fcae

Please sign in to comment.