How To Make A True First-Person Shooter in Unreal Engine 5 - Part 2.2: Rotating Spine Bones
Table of Contents
Introduction
In this tutorial, we will learn how to rotate your character's spine bones in Unreal Engine 5 to respond to camera and mouse input. This functionality is essential for creating a true first-person shooter experience, allowing players to look up and down fluidly. This guide is part of a broader series on developing a first-person shooter, and it will build on concepts introduced in previous parts.
Step 1: Add Pitch Variable
- Open your character blueprint in Unreal Engine.
- Create a new float variable named
Pitch. - This variable will store the up and down rotation based on mouse input.
Step 2: Pass Pitch Variable to AnimBP
- Open your Animation Blueprint (AnimBP).
- In the Event Graph, drag off the
Try Get Pawn Ownernode. - Connect it to a
Get Control Rotationnode. - From the Control Rotation, break the structure to access the Pitch value.
- Set your
Pitchvariable to the Pitch output from the Control Rotation.
Step 3: Rotate Spine Bones in Anim Graph
- Navigate to the Anim Graph of your AnimBP.
- Use a
Transform (Modify) Bonenode to adjust the spine bones. - Set the following parameters:
- Bone to Modify: Select the spine bone you want to rotate.
- Translation: Leave at (0,0,0).
- Rotation: Use the
Pitchvariable to change the rotation along the appropriate axis (usually the X-axis).
Step 4: Add Layer Blend Per Bone Node
- Add a
Layer Blend per Bonenode to your Anim Graph. - Connect the output of your previous node to the layer input of the blend node.
- Set the bone at which the blend will start (usually the root or a specific spine bone).
- Add a new layer for the spine rotation.
Step 5: Set AnimBP
- Go back to your character blueprint.
- Make sure your character uses the correct Animation Blueprint.
- Check that the
Pitchvariable is being updated properly and passed to the AnimBP.
Step 6: Fix Alignment with Arrow Component
- In your character blueprint, ensure that your arrow component is aligned correctly.
- Adjust the arrow component’s rotation to match the intended forward direction of your character.
Step 7: Fix Texture Streaming Pool Over Budget Warning
- If you encounter a warning about the texture streaming pool being over budget, go to the project settings.
- Increase the texture pool size or optimize your textures to stay within budget.
Conclusion
You have now set up your character to rotate its spine bones based on camera input, enhancing the first-person shooter experience. Ensure to test the functionality in-game to verify the rotations are as expected. For further enhancements, consider exploring additional animation blending techniques or refining the character's movement mechanics. Continue with the next parts of the series to expand your game development skills!