Search
  • Gavin.M (Tesla Dev)

Paragon - Setup a Base Character



Requirements: Unreal Engine 4.19+, Paragon Characters from UE4 Marketplace.


In this tutorial, we are going to setup a base character that we can use as a parent to any of the other paragon characters on the UE4 marketplace.



YouTube Video Tutorial







Create the base character blueprint

We will start off by creating a character blueprint class in a folder named “Blueprints” inside the content browser (right click in content browser > blueprint class > character). We can name the character blueprint: BaseCharacter_BP.


Inside the blueprint, we can add a character mesh by selecting the mesh component and dropping down the skeletal mesh slot on the details panel, here you can apply any of the paragon characters you have downloaded. But keep in mind that it doesn’t really matter which one you choose here because we are going to be creating child blueprint classes and changing this.


Drag the character down so the feet hit the bottom of the capsule and rotate the character -90.0 on the Yaw. The mesh should face the same direction as the forward facing arrow.


Setting up the camera

We are going to be setting up a third person camera, so to prevent the camera clipping through walls and acting un-natural we are going to first, attach the camera to a spring arm.


Make sure you have the character mesh selected and then add a new component, search for spring arm. Make sure the spring arm is rotated behind the character and move it up around the shoulder/neck height.


To add the camera, we want to attach it to the end of the spring arm. We can do this by selecting the spring arm first and then adding the camera component. You should see it has attached to the end of the spring arm.


Adjusting camera position


To adjust the camera position, we do not want to move the spring arm or the camera. Instead we want to select the spring arm and then adjust the “target arm length” value. If we want to adjust the camera so it leans over one shoulder, we can adjust the Y value of the socket offset. (Just below the target arm length).






Camera/Character Rotation.


When we move the mouse, we are going to pan the camera around the character in a free look style. To do this we must select the spring arm and check “Use Pawn Control Rotation”. This will now make the spring arm listen and update to yaw and pitch input.


To stop the character from rotating while we pan the character, select the class defaults button on the top tab, then uncheck “use controller rotation yaw” on the details panel.


If the character is facing one direction but our camera is facing another, when we move, we want the character to rotate towards the direction of our movement. To do this, we want to select the character movement component and check “orient rotation to movement”. Note: You can use the filter bar and just search for rotation.



Setting up movement input

Input mappings


First we want to make sure we have some input mappings. To add input axis and input action events, go to edit > project settings > input.


Here are my settings:





Movement Input Code


To add WASD movement to move our character, we want to right click on the event graph and search for “Move forward” and “Move Right” input axis events. To make the character move we can call the “add movement input” function, we can duplicate it with ctrl + w, so we have one for each input event.


Make sure the execution pins are connected and that the axis value is hooked up to the scale value.


To calculate the world direction we want to get the control rotation from the player controller.


We can do this by right clicking searching for the “Get Control Rotation” function. This returns a rotator that contains Roll, Pitch and Yaw.


We want to filter out the Roll and Pitch so we are just left with the Yaw. First, split the return value by right clicking on it and select split struct. Then right click in the event graph and search for “make rotator”. Plug the yaw from the get control rotation into the yaw input of the make rotator. Make sure you leave the pitch and roll empty.


From the make rotator we can drag out the return value and call the “get forward vector” function and use this as the world direction input for move forwards. Then we can repeat this but call the “get right vector” function for the move right input event.


Select all your nodes and hit ‘C’ to add a comment section, we can name this “Movement Input”. With the comment selection selected, you can adjust the font size and color on the details panel.


Mouse Input


To add mouse input, right click and search for the “LookUp” and “Turn” axis events. To look up and down, we can call the “add controller pitch input” function.


To look left/right, call the “add controller yaw input” function.


Make sure the execution pins are connected together and that the axis values are connected. We can also add a comment section for this named “Mouse Input”.






Choosing which character to spawn as


To select which character we want to spawn as, we need to create a Game Mode. Do this by right clicking in the content browser and adding a new blueprint class, then select Game Mode Base. Name this Paragon_GameMode_BP.


To assign the game mode to our map open up the world settings (settings on top tab) and then drop down the game mode override to select the Paragon_GameMode_BP.


Note: You can assign a default game mode by going to edit > project settings > maps + modes


Now open up the Game Mode and drop down the default pawn class to select your character. Currently we only have the BaseCharacter_BP. This is okay, we can go ahead and test the character.


Hit Play, you can go into full screen mode by pressing F11.


You should now be able to pan the camera around the character and when you move, the character will move towards the direction of the camera and auto rotate towards this direction.



Functions!


We are now going to create some functions in our BaseCharacter_BP that will help us drive our animations through an animation blueprint. We will be setting up an animation blueprint in the next tutorial but we will create these functions now. This way, we don’t have to repeat the creation of these functions for each character.



(Example of how we will use these functions in an animation blueprint, in the next tutorial.)


Calculate Aimoffset

(Screen shot of final function below)


When we look around, we want the character to look in direction that the camera is facing in, we can do this by using an Aim Offset. However, the Aim Offset will require a pitch/yaw input. So, we are going to create a function that will calculate the Yaw + Pitch of our character blueprint, that we can then use for the aim offset.


To start, create a new function on the function tab of the character blueprint. Name this “Calculate Aimoffset”.


We are going to create our Aim Pitch and Aim Yaw variables right away.


Click the add variable button on the variable tab. Make sure it is a float and name the first one Aim Pitch and repeat this and name the second, Aim Yaw.


We can put variables into a category by selecting the variable and typing in a category name. Once the category has been created you can drag the other variable into this category on the variable tab.


Drag both of the variables out onto the event graph and use the “set”, make sure the execution pins are hooked up from the function start. (You can hold left alt while dragging and releasing to auto “set”, or left ctrl to auto “get”).


To calculate the aim pitch/yaw, right click on the graph and call the “get base aim rotation” function. Right click again and call the “get actor rotation” function. Now drag out the return value of the base aim rotation and search for the “Delta (rotator)” function. Make sure the “get actor rotation” is hooked up into the B input.


Right click on the return value of the Delta (rotator) and split the struct pin to gain access to the pitch and yaw.


Adding smoothing to Aim Pitch/Aim Yaw


We want to smooth these values to make the character feel more natural, to do this we are going to call the “f interp to” function, which stands for float interpolation. We can duplicate it and we want to make sure the float output is connected to the set of the aim pitch/aim yaw.


The current input is going to be the current value of Aim Pitch/Aim Yaw. Drag your variables from the variable tab and use a “Get”.


The target value is going to be the output from the delta rotator.


We can use a function named “Get World Delta Seconds” for the delta seconds.


We can put a value of 10 for the interp speed, you can adjust this value. The higher the value, the faster the smoothing.


Look behind Jitter Fix


By default when we move forwards and look behind us while applying an aimoffset, the character will jitter and it will look un-natural.


To fix this, we are going to create a cut off point for the aim offset and reset the character to look forwards once we look so far behind us.


Start by breaking the link on the target input of the finterp to for the Aim Yaw. (Left Alt + Left Click). Drag out from the left of the target and use type in “select”.


The select node will select either A or B based on the condition we plug into it. To create our condition, drag out from the Yaw output of the Delta and release, type and search for “ABS”. We are going to get the absolute value of our Yaw. Then drag out from the ABS output and search for “float > float”.


Now we can compare to see if our yaw is past a specific angle. Let’s compare it to the value of 135 (135 degrees) by typing in this value into the input box. Now we are left with the red Boolean output. This condition can be plugged straight into the select node.


Now we can select a value for the yaw if our condition is true or false, plug the Boolean return into the index. If our condition is true (if our yaw is past 135 degrees), we can put in a value of 0 to make the character smoothly reset back to looking forward.


If our condition is false (if we haven’t reached past 135 degrees on the yaw), we want the character to still continue following the yaw of the mouse, so we can plug the Yaw of the delta straight into this false input.


Returning the values on the function


We want to return the Aim Pitch/Aim Yaw on the output of this function. To do this, select the purple node at the start of the function, then on the details panel on the right, add in two new input parameters. Make sure they are float values and name one Aim Pitch and the other Aim Yaw.


You should now have another node in the graph. This is the output return of the function. Drag this to end of the function and make sure the execution pins are connected up. Plug in the Aim Pitch/Aim Yaw variables into the parameters by getting them from the variable tab or by using the return pin from the set of the Aim Pitch/Yaw.


Phew! We have now created the function that will calculate the Aim Offset.


Final result:






Calculate Lean

(Screenshot of final function below)


When we run and turn, we want the character to lean in the direction that we turn in. So we are going to create a function that will calculate our lean amount.


Add in a new function named “Calculate Lean”. Add in one float input parameter named “Lean Sensitivity”. (We will be able to control the sensitivity of the lean for each character in their animation blueprint.)


Start by calling “Get Actor Rotation” and storing this as a variable named “Previous Character Rotation”. We want to make sure we always call the set of the previous character rotation at the end of the function.


Now drag the “Previous Character Rotation” off from the variable tab and use a “Get”. Drag out from this and call the “Delta (Rotator)” function. Make sure the “Get Actor Rotation” is plugged into the B input.


Now we can right click on the return value of the delta. We are going to multiply the yaw by our Lean Sensitivity input. Drag out from the yaw and call “float * float”. Plug the Lean Sensitivity input from the function start into the multiply. We can now promote the output of the multiply to a variable named “Lean Amount”.


We can also apply some smoothing to this. Use the “F Interp To” function and make sure the output/return value is connected to the Set for “Lean Amount”.


Use the Lean Amount variable (Get) for the Current input.

Use the output of the multiply for the Target input.

Use “Get World Delta Seconds” function for the Delta Time.

Use a value of 10.0 for the interp speed (the higher the value, the faster the smoothing).


Once you have done all of this, double check all your connections/execution pins.


We want to return the Lean Amount in the output of this function. Select the purple node at the start of the function and add one new output parameter, name it “Lean Amount”. Plug the Lean Amount variable into this.


Neat! That is our Calculate Lean function complete.


Final result:




Calculate Speed

This function is fairly simple. We are going to calculate the speed of the character. To do this create a new function called “Calculate Speed”.


Add one float output parameter named Speed.


To calculate the speed of the character, right click on the graph and call “get velocity”, drag the vector return value out and call the “vector length” function. This outputs our speed, we can plug this straight into the Speed output.


Final result:





Conclusion


We are now ready to move onto setting up a child blueprint class for a Paragon Character that will include an animation blueprint!



- Gavin Milroy (Tesla Dev)


0 views