In earlier post I’ve described how to move assets from Shooter Game Example. To complete this tutorial you will need to move Animations and Characters folders to your project.
<strong>This Tutorial has been created using Unreal Engine 4.8.2</strong>.
Make sure you are working on the same version of the engine.
First of all I’ll write down what I would like to achieve:
- I want to have animated hands attached to my first person character (which is GameplayPlayerCharacter in this case),
- Hands should be aiming where I’m aiming and have idle animation,
- If camera will be outside of my character I will see entire TPP mesh,
- Character mesh should have idle animation,
- I want to see my aiming from TPP mesh as well,
Basically I wasn’t able to find a package with animated hands and character mesh. That’s why I will use assets from Shooter Example. You can find separated hands in Unity Asset store.
Fixing assets after importing.
There is a couple of issues after copying assets to our project. Let’s deal with Materials – create new material like this:
Name it M_Player and assign to HeroTPP and HeroFPP meshes. Now we aren’t focusing on graphics side so let’s leave it like it is. Later I will explain how to make this material better.
Let’s move to HeroFPP_AnimationBlueprint and delete every variable and everything from AnimGraph and EventGraph. Do the same with HeroFPP_AnimationBlueprint. They should be clean without any functionality because Shooter Game uses C++ to drive ShooterCharacter which we don’t have here.
GameplayPlayerCharacter adding hands and TPP mesh.
Open GameplayPlayerCharacter and in viewport lets update/add components:
– Select TPP mesh and use animation blueprint: HeroTPP_AnimationBlueprint,
– Location: (X=-0.000002,Y=-0.000001,Z=-86.000000) and Rotation: (Pitch=-0.000000,Yaw=-90.000000,Roll=-0.000000)
– Set Owner No See to True, (thanks to this if we will be in different camera our TPP mesh will not be visible)
- Add new component: Camera
– Set its location to (X=0.000000,Y=0.000038,Z=75.990540)
– Set Use Pawn Control Rotation to true,
- Add new Skeletal Mesh component and name it FPPMesh
– Move FPPMesh to Camera. So it will be attached to the Camera,
– Select FPPMesh and use animation blueprint: HeroFPP_AnimationBlueprint,
– Location: (X=-9.983782,Y=8.026691,Z=-145.999725),
– Rotation: (Pitch=-0.000000,Yaw=-90.000000,Roll=-0.000000)
– Set Only Owner See to True, (thanks to that only if we are in this pawn’s camera FPP mesh will be visible)
- Now go to Class Defaults and disable Use Controller Rotation Yaw,
That’s all here. Your components should look like this.
Now let’s go to HeroFPP_AnimationBlueprint and just add FPP_LauncherIdle to your Animation Pose.
It’s all here. Compile and close.
Now go to HeroTPP_AnimationBlueprint and add two new variables: Pitch and Yaw – both should be float, default 0. Then add this to your Event Graph:
Basically we need Pitch and Yaw for our AimOffset. You can read about aim offsets here. Just recreate this animation blueprint:
This is making sure that legs won’t be animated during AimOffset. I’ve used cached pose NormalMovement which can be created by right-click -> New Save Cached Pose. Later on you can right-click and select this cached pose as I did. Another thing is Slot – I’ve used two: UpperBody and FullBody. You can create those by right-click -> Slot’DefaultSlot’ and then just open the magnifier.
At this point if you don’t know how to use animation blueprints you should watch these tutorials made by Epic.
Now let’s test this out! To do so place a camera in your level to be sure that it can see player. (PlayerStart) And in Level Blueprint just add these to toggle camera:
And run the game!