The Camera Movement component manages the movement of the main camera and the minimap camera.
When you’re creating a new map using the RTS Engine menu editor, this component is attached to an object called “UnitManager”.
- Main Camera: Main camera object field (in the demo’s case, it’s the same object that includes this script).
- Camera Height: The height of the camera which is the camera’s object position on the y-axis.
- Flat Terrain: Drag and drop the map’s flat terrain in this field.
- Movement Speed: The movement speed of the camera.
- Movement Keys: Set the four keys that the player can use to move up, down, right and left.
- Move On Screen Edge: If true, then when the player’s mouse is on the screen’s edge, the camera will move in the edge’s direction.
- Screen Edge Size: Define the size of the screen edge size in this field.
- Screen Limit: If true, then the camera’s movement will be limited by maximum (Max Pos) and minimum (Min Pos) values on both the x-axis and the y-axis.
- Panning: Enable/Disable panning.
- Panning Key: Key that triggers the main camera panning.
- Panning Speed: How fast should the camera panning be?
- Zoom Enabled: If true, then the player will be able to zoom in and out.
- Can Zoom With Key: If true, the player will be able to use keys to zoom in and out.
- Zoom In/Out key: Pick keys that allow the player to zoom in and out.
- Max & Min FOV: Maximum and minimum zoom values.
- Zoom Smooth Time: Determines how fast the zoom in/out process is.
- Zoom On Mouse Wheel: If true, then the player will also be able to use the mouse wheel in addition to the keys above in order to zoom in and out.
- Zoom Scroll Wheel Sensitivity: Self-explanatory.
- Zoom Scroll Wheel Speed: Self-explanatory.
- Can Follow Unit: if true, then the player will be able to follow a selected unit with the camera by pressing a certain key.
- Follow Unit Key: The key to press to be able to follow a selected unit with the camera.
- Minimap Cam: Drag and drop the minimap camera in this field, the minimap camera should be a camera that looks at all the map’s terrain at the same time. It shouldn’t have any GUI Layer, Flare Layer or anything else but the camera component. You can also play with the Viewport Rect values in order to place the camera in the screen.
- Offset X & Z: When the player clicks on a position in the map in the minimap’s camera, the camera position shifts to that position. The offset X & Z are two values added to the main camera’s position respectively at the x-axis and z-axis when applying that move.
- Minimap Canvas: A separate canvas to show the minimap cursor texture at.
- Minimap Cursor: UI Image, child of the “Minimap Canvas”. This UI Image indicates where the camera is looking at exactly in the minimap.
- UI Cam: Drag and drop the UI camera in this field.