Designer, Personal project
August 20, 2022
Bullet Points:
- Used Unreal Engine blueprints to modify the base top-down camera to behave more like a cRPG camera.
- Used action mappings and axis mappings to translate user input from multiple sources to control camera actors.
Full description
For this project, I wanted to create a camera that behaved more like a classic cRPG camera than the default one available in the top down starter for Unreal Engine 5. This project was mostly done to get a base familiarity with UE5 because of the simplicity of the project itself.
For this project, I decided on the path of creating a new camera actor, the default camera remains the camera in the character blueprint until the point where the player uses a movement key to separate the camera from the player, at which point it sets the custom camera as the view target and allows movement throughout the world. When the player presses the ‘find player’ button, the default camera is then set as the view target, and the custom camera teleports back to the player and attaches itself to them.
Both cameras have zoom and rotation ability, within certain bounds.
For zoom, I simply took the player’s scroll wheel input, multiply that by a zoom speed variable and add that to the arm length of a spring arm – to keep the camera bound, there is an upper and lower limit to the arm length, before actually setting the arm length I check that the targeted arm length is in range of these limits.
For rotation, the Z axis is completely free to rotate around, while the Y axis is bound between 10 and 80 degrees. I take the player’s axis input, multiply that by a rotation speed before turning that into a rotator. For the Y axis, this checks if it would be in range before adding the rotation – While Z axis directly adds it.
Only the custom camera actor is capable of movement however. On pressing of a movement key, the player character checks if the active camera is the the player or custom camera, if it’s the player’s camera it sets the custom camera as the view target. To move the custom camera, I again take the input axis and multiply it by speed, then I remove the Z axis from the camera’s forward vector to keep it bound to a plane and multiply that by the input. The camera’s current location is then added by the product of the forward vector and input to set the world location.
To keep the player from losing their character, a button was added that when pressed resets the custom camera to the player’s location, and changes the view target back to the player’s camera.