1.Blue print setup:
Open third person template in game
Add AnimStartPack to the project in Epic
R click → Blue Print Class → Character, name as BP_Character
Again Blue Print class → Player Controller, name as BP_Controller
.....Game Mode Base, name as BP_Gamemode
2.Setup input of mouse and keyboard/gamepad:
Project Setting → Engine → Input → Binding
Action Mappings, click + 3 times (name as Jump, Crouch, Punch), set the commands for each as follow:
Remark: Apply each action in mouse, keyboard and gamepad respectively
Axis Mappings, add 6 times, name as Forwardmotion, Rightmotion, Turnrate (Gamepad) YAW, Turn (Mouse) YAW, LookupRate (Gamepad) PITCH, Lookup (Mouse) PITCH, set as follow:
Remark:
-set scale as -1 if the button is opposite direction from scale 1
-Command of Y axis for lookup/down, X-axis for look left/right
3.Create Basic Material for Character:
R click in Broswer → Material, name as M_Material (main material)
→ R click on it, create Material Instance, name as MI_color
Open the Material event graph
→
R click on base color, metallic, specular, and roughness, (emissive optional) , promote to parameter for each of them
→ Hold L + L click (create Lerp node, to mix A,B, alpha)
→ create node “Power” (to multiple), set Const Exponent as 4 (@bottom left)
→ create node “Fresnel” (to make edges draker, i.e. more reflective)
Open Material Instance
→
tick roughness, specular and base color, set the value and choose color wanted:
Open the character Mesh, choose MI_color material just created at Element 0
4.Creating a 1D Blend Space/animation
Content Broswer, R click → Animation → Blend Space 1D → Choose the skeleton mesh used, name as 1D_idle walkrun → open it
→ drag stand, walk and run animation at Asset Broswer to the timeline at 1st, 2nd and last line (hold shift and move the mouse from L to R to see the blend actions, the cross cursor will move along)
→
In Asset Details → Axis Setting, Name as Speed, min and max value as 0 and 375
Create another Blend Space 1D, if need other blend animation. e.g. crouch, jump, holding rifle....
5.Animation Blueprint Setup
Content Broswer, R click → Animation → Animation Blueprint → AnimInstance → choose needed target skeleton, name as BP_animation → open it
→
To Event Graph → create node “? Is Valid”
In My Blueprint (bottom L corner) → Variables. create 2 booleans and 1 Float, name as follow:
Drag all 3 variables (as Set) in the graph. Connect the node graph as follow:
For organizing purpose, select all 3 variables in graph → R click → Collapse to Marco (for grouping), name as SetVariables → Open it
→
Connect Curching variable to output
→ copy “Try get pawn owner” green node from main event graph → paste 2 times in SetVariables graph
→ create and connect “movement” and “Falling” nodes to “Air” variable
→ create and connect “velocity” and “vector” nodes to Speed variable:
Now in main event graph, will see the active orange arrow:
To AnimGraph → create and add “New State Machine”, name as Locamotion → connect to Output Pose
→
double click State Machine node → select Asset Broswer (bottom R corner), drag the 1D idlewalkrun animation (created eariler) in the graph
→ also drag jump start, jump loop, and jump end animation, name as them in graph accordingly
Connect Entry node to 1d idlewalkrun node
→ double click idle node, drag Speed variable directly on the idle node (to control the speed), do it on crouch node too:
→ Compile
Back to Locamotion, Connect to crouchwalk node, double click on double arrow icon (for controlling transition)
in double arrow node, drag IsCruching variable to Result node:
Back to Localmotion, connect crouch node back to idlewalk node, open the new double arrow icon
→
repeat the same step but this time, add “NOT” node in between (i.e. if he is not crunching, will transit to result animation)
Connect both crouch and idlewalk nodes to jump start nodes
→ Open the double arrow (transition), place In Air variable this time (i.e. when character in air, he transits to jump animation)
Connect Jump start node to Jump Loop node, open its transtion → create node “Time remaining” and “Less” as follow, set less value as 0.5 (i.e. if time remaining ration less than the 0.0 value, will transit to loop jump):
Connect Jump loop to jump end, its transition as:
Connect the jump end node back to idelwalk:
Set its transtion:
Remark: play around the less value here if the animation looks weird after transit from jump to walk
To check the animation if working:
Select Anim Preview Edit (bottom R corner), tick the variables (in Air, Is Cruching, Speed...)
6.Setup Character Blueprint:
Open the BP_Character created in ch.1 → Viewport
Select Mesh (CharacterMesh0) in Components (top L corner)
→ Details → Mesh → Skeleton Mesh: select the character mesh
→ change to front viewport → set snap size from 10 to 1
→ move the character fitting the bottom of capsule of his feet
rotate character 90 degree, so the capsule arrow is in same direction:
Still in Mesh component → Animation mode (In Details), make sure it’s “Use Animation Bleuprint”
→ Anim Class: choose the BP_Animation (created in ch.5)
In Components → +Add → type SpringArm, then also add Camera (make sure the camera is parented under SpringArm)
→ Set the camera location as 0,0,0 (so the camera is just behind the springarm)
→ Select the springArm, move its Z-axis up so the camera is on up the character head level
Select BP Character (self) top layer in Component → Details → Pawn → untick Use Controller Rotation Yew
→
In SpringArm → Details → Camera Settings → tick Use Pawn Control Rotation
→
Select Character Movement (in Components) → Details →
1.Jump Z Velocity: 650, Air Control: 0.25 (i.e. he can jump back and forth during jumping, set as 0 if want to be realistic, as real life is like that);
2.tick “Orient Rotaion to Movement” in Character Movement column in Details
3. tick “can crouch” in NAV movement
Continue: