Spielerando

Turning the view with the mouse swings the map away instead of around a spot

Turning and tilting a 3D map view should circle the spot at the middle of the screen, as if walking around a table. Rotating the camera on its own spot sweeps the whole map away. Here is how to describe the camera so that turning keeps the spot, with limits for tilt and a way back to a position.

Why this works

People turn a view to look at something, so that thing must stay put. Storing the point being looked at, and computing where the camera sits from it, means turning, panning and zooming each change exactly one thing and never disturb the others.

When not to use it

Do not use it for a camera that rides behind a character or flies freely, as in a first-person game. There the camera itself is the thing that moves, and you steer its own position and direction instead of swinging around a point.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 32 lines of example code with 3 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "Turning the view with the mouse swings the map away instead of around a spot" (read_entry strategy-orbit-around-ground-point) in my game. Build it step by step, and show me how you checked that it works.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP