Overhead Camera Movement

Hi there, I’m currently working on a strategy game and and I’ve been wondering how I would go about creating a camera system that functions like so:

The camera is a bird’s-eye view, you right click and drag to move the camera around. There are barriers which prevent the camera from moving out of a certain area.

Here’s an image to further explain

If you need me to explain into further detail just ask, all help & feedback is appreciated. Thanks

4 Likes

Height Positioning

  • Set a constant Y position to the camera. However high you want it to be. You could even put some math in to raise or lower the Y position depending on which terrain you’re looking at.

Camera Boundaries

  • Set 4 number values as your boundaries. A minimum X, maximum X, minimum Z and maximum Z. This can be done by values or parts that you add in the world.

Holding the Right Mouse Button

  • Set a boolean to true and false when the right mouse button goes down and up respectively. This will indicate if the user is holding down the mouse button or not.

Panning/Positioning the Camera

  • When the mouse is moved, check if the boolean value is true. If it is, the right mouse button is held. Pan the camera by setting its X and Z position relative to the mouse movement. (Will require some math).
  • Before setting the camera position, clamp the X and Z values to the minimums and maximums first. Then, you can set the camera position to the final values. Limiting how far the player can pan around.

This should all be done in a LocalScript.

References you can use to achieve the fuctionality:
Input Detection: UserInputService
Camera Manipulation: Camera Manipulation
Mouse Movement: GetMouseDelta
Clamp Function: Math Library

Good luck!

4 Likes