Starting with Unreal Engine 5 (UE5) as a new developer can be challenging, but I'll guide you through the process of creating a top-down camera that follows the player character step by step.
-
Install Unreal Engine If you haven't already, download and install Unreal Engine 5 from the official website.
-
Create a new UE5 project Open Unreal Engine 5, click on "New Project," and select the "Blank" template. Name your project and choose a location to save it.
-
Create a new Blueprint Class In the Content Browser, right-click and select "Blueprint Class." Choose "Actor" as the parent class and name it "TopDownCamera."
-
Set up the camera In the TopDownCamera Blueprint, add a "Camera" component. Set the location to (0, 0, 200) and rotation to (0, 0, 0).
-
Add a Spring Arm Add a "Spring Arm" component to the TopDownCamera Blueprint. Set the location to (0, 0, 200), rotation to (0, -90, 0), and target arm length to 300.
-
Set the Spring Arm as the parent of the Camera �-\ Set the Camera's parent to the Spring Arm.
-
Create a Scene Component �-\ Add a "Scene Component" and name it "Target." Set its location to (0, 0, 0).
-
Create a Player Character Blueprint �-\ In the Content Browser, right-click and select "Blueprint Class." Choose "Character" as the parent class and name it "MyCharacter."
-
Add a Camera Boom �-\ In the MyCharacter Blueprint, add a "Scene Component" named "CameraBoom." Set its location to (0, 0, 0) and rotation to (0, -90, 0).
-
Add a Static Mesh �-\ Add a "Static Mesh" component named "CharacterMesh." Set its location to (0, 0, 0) and rotation to (0, 0, 0). Assign a mesh for your character.
-
Attach the TopDownCamera to the MyCharacter �-\ In the MyCharacter Blueprint, add a "Spawn Actor From Class" node and set the Class input to the TopDownCamera Blueprint.
-
Set the TopDownCamera's location �-\ Add a "Set Actor Location" node and connect it to the "Spawn Actor From Class" node. Set the Location input to (0, 0, 200).
-
Set the TopDownCamera as a child of the Camera Boom �-\ Add a "Set Actor Parent" node and connect it to the "Spawn Actor From Class" node. Set the New Parent input to the Camera Boom component.
-
Implement camera movement �-\ In the MyCharacter Blueprint, add an "Event BeginPlay" node.
-
Get the player controller �-\ Add a "Get Player Controller" node and connect it to the "Event BeginPlay" node.
-
Get the player's location �-\ Add a "Get World Location" node and connect it to the "Get Player Controller" node. Set the First Person Camera location as the Target input.
-
Set the TopDownCamera's location �-\ Add a "Set Actor Location" node and connect it to the "Get World Location" node. Set the Actor input to the TopDownCamera Blueprint.
-
Implement camera height adjustment �-\ Add an "Event Blueprint Update Animation" node.
-
Get the player controller �-\ Add a "Get Player Controller" node and connect it to the "Event Blueprint Update Animation" node.
-
Get the player's location �-\ Add a "Get World Location" node and connect it to the "Get Player Controller" node. Set the First Person Camera location as the Target input.
-
Get the player's rotation �-\ Add a "Get Control Rotation" node and connect it to the "Get Player Controller" node.
-
Make a rotator �-\ Add a "Make Rotator" node and connect it to the "Get Control Rotation" node. Set the Pitch input to 0.
-
Interpolate the rotator �-\ Add a "RInterp To" node and connect it to the "Make Rotator" node. Set the Target input to the "TargetRotationOffset" from the TopDownCamera Blueprint's FollowTimeline.
-
Set a timer for the interpolation �-\ Add a "Set Timer by Function Name" node and connect it to the "RInterp To" node. Set the Function Name input to "AdjustCameraHeight."
-
Implement the AdjustCameraHeight function �-\ Add an "AdjustCameraHeight" function node and connect it to the "Set Timer by Function Name" node.
-
Get the player controller �-\ Add a "Get Player Controller" node and connect it to the "AdjustCameraHeight" function node.
-
Get the player's location �-\ Add a "Get World Location" node and connect it to the "Get Player Controller" node. Set the First Person Camera location as the Target input.
-
Get the player's rotation �-\ Add a "Get Control Rotation" node and connect it to the "Get Player Controller" node.
-
Make a rotator �-\ Add a "Make Rotator" node and connect it to the "Get Control Rotation" node. Set the Pitch input to 0.
-
Interpolate the rotator �-\ Add a "RInterp To" node and connect it to the "Make Rotator" node. Set the Target input to the "TargetLocationOffset" from the TopDownCamera Blueprint's FollowTimeline.
-
Set the camera's height �-\ Add a "Set Actor Location" node and connect it to the "RInterp To" node. Set the Location input to the TopDownCamera Blueprint's location + the "TargetLocationOffset" from the FollowTimeline.
-
Save and compile your Blueprints �-\ Save your changes and compile the TopDownCamera and MyCharacter Blueprints.
-
Test your game �-\ Run your game and test the camera's behavior.
Remember that this is a basic example, and you might need to adjust the settings and logic to fit your specific game requirements. As a new developer, take your time to understand each step and experiment with different settings to achieve the desired camera behavior.