C++ RTS Camera On Wiki

Hey Everyone!
I just wanted to let you know that I have a working implementation of a simple RTS Camera. I thought I would share my code because I couldn’t find much other information on creating a RTS Camera via C++.

Let me know if you have any issues with it, or if you have any suggestions on what to change and or add.

Connor Brewster

I think using the spectator pawn as your base pawn is a bad idea. The spectator is not just there to be a pawn without mesh but it represents a pawn that is not in the game itself. For example you can have a full multiplayer game but let more spectators join the session, its like the audience of a match. Just Inherit from APawn, should be easy to change.

Another issue is that you do not use the DeltaTime for your movement, you could just multiply CameraMovementSpeed with the DeltaTime. This will make it FPS independent and the speed will be expressed in Units per second.


Hi, thanks for mentioning the deltaTime, I was going to fix that, but forgot about in while working on other thing. Also I understand the idea of having a spectator pawn but are there any specific issues related to deriving my default pawn from ASpectatorPawn. The player’s pawn itself should not contain a mesh as it is just acting as a way of controlling the camera, which is what this class allows me to do. Also the Strategy Game uses the ASpectatorPawn; however, that game is not multiplayer, would using this class cause any specific issues multiplayer wise?

Connor Brewster

I do not think you would come into real issues, but the spectator pawn has a special meaning, so Epic could in the future add functionality that might break your code because you have not followed the rules as expected. I would create a Pawn that does the same as the spectator pawn:

AMyPawn::AMyPawn(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP
    // ...

This way you get rid of the mesh component and you use the SpectatorMovement component so the movement will work the same way as your current solution.

I’m not a multiplayer pro (targeting to make a single player RTS with a later possibility to extend to multiplayer), but if I understand correctly: if you have player-controllers probably it does not really matter whether the camera-player is present on other clients or not, they don’t need it at all; more exactly it is better if they don’t even have the chance to know what other players are viewing, thus player-camera pawns or spectator-pawns are better if present only on local client and server.


I made an extended version based on it, having more features (movement, rotation, and zoom by keys and mouse combinations in various ways), project creation is also described.
Get it from here: RTS Camera C++ - Community Content, Tools and Tutorials - Unreal Engine Forums