Skip to content

Commit

Permalink
Optionally align camera while moving.
Browse files Browse the repository at this point in the history
  • Loading branch information
awgil committed Feb 28, 2024
1 parent 0a9ec17 commit 80a8746
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions vnavmesh/IPCProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public IPCProvider(NavmeshManager navmeshManager, FollowPath followPath, MainWin
Register("Nav.Reload", () => navmeshManager.Reload(true));
Register("Nav.Rebuild", () => navmeshManager.Reload(false));
Register("Nav.IsAutoLoad", () => navmeshManager.AutoLoad);
Register<bool>("Nav.SetAutoLoad", v => navmeshManager.AutoLoad = v);
Register("Nav.SetAutoLoad", (bool v) => navmeshManager.AutoLoad = v);

Register<Vector3?, Vector3, float>("Query.Mesh.NearestPoint", (p, r) => followPath.Query?.FindNearestPointOnMesh(p, r));

Expand All @@ -26,12 +26,14 @@ public IPCProvider(NavmeshManager navmeshManager, FollowPath followPath, MainWin
Register("Path.IsRunning", () => followPath.Waypoints.Count > 0);
Register("Path.NumWaypoints", () => followPath.Waypoints.Count);
Register("Path.GetMovementAllowed", () => followPath.MovementAllowed);
Register<bool>("Path.SetMovementAllowed", v => followPath.MovementAllowed = v);
Register("Path.SetMovementAllowed", (bool v) => followPath.MovementAllowed = v);
Register("Path.GetAlignCamera", () => followPath.AlignCamera);
Register("Path.SetAlignCamera", (bool v) => followPath.AlignCamera = v);
Register("Path.GetTolerance", () => followPath.Tolerance);
Register<float>("Path.SetTolerance", v => followPath.Tolerance = v);
Register("Path.SetTolerance", (float v) => followPath.Tolerance = v);

Register("Window.IsOpen", () => mainWindow.IsOpen);
Register<bool>("Window.SetOpen", v => mainWindow.IsOpen = v);
Register("Window.SetOpen", (bool v) => mainWindow.IsOpen = v);
}

public void Dispose()
Expand Down
4 changes: 3 additions & 1 deletion vnavmesh/Movement/FollowPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Navmesh.Movement;
public class FollowPath : IDisposable
{
public bool MovementAllowed = true;
public bool AlignCamera = false;
public bool UseRaycasts = true;
public bool UseStringPulling = true;
public float Tolerance = 0.5f;
Expand Down Expand Up @@ -60,10 +61,11 @@ public unsafe void Update()
else
{
_movement.Enabled = MovementAllowed;
//_camera.Enabled = true;
_movement.DesiredPosition = _waypoints[0];
_camera.Enabled = AlignCamera;
_camera.SpeedH = _camera.SpeedV = 360.Degrees();
_camera.DesiredAzimuth = Angle.FromDirectionXZ(_movement.DesiredPosition - player.Position) + 180.Degrees();
_camera.DesiredAltitude = -30.Degrees();
}
}

Expand Down

0 comments on commit 80a8746

Please sign in to comment.