While creating patterns I did find them to be really hard. I came up to idea to create aim functionality that will trigger slomo as well. In this tutorial I will do right mouse button aim which can be used for X amount of time.
This Tutorial has been created using Unreal Engine 4.10
Make sure you are working on the same version of the engine.
Live Stream
You can watch Live Stream of developing this Tutorial:
Slomo
Basically I want to do slomo when enabling aim but for player and current weapon I want normal time dilation. This way I will be able to fire normally without slomo. Devastating feature… that’s why player will have only 6 seconds to aim during gameplay. Use wisely.
Creating Aim Widget
Create new widget blueprint named HUD_AimLeft. Try to recreate this hierarchy:
Now open Event Graph and add two new custom events OnAimEnter and OnAimLeave with one float input TimeLeft:
So basically when we enter aim mode widget will toggle progress bar.
Next add another custom event named UpdateWidget with two float inputs TimeLeft and TimeLeftMax:
I will update this widget from GameplayCharacter when we will be in aim mode. This will make sure to update the progress bar and text.
That’s all here!
Updating Weapons For Slomo
Open BP_BaseWeapon and add one custom event named SetTimeDilation with one float input named Value:
Now open BP_Weapon_AssaultRifle and in Fire event make sure you calculate timer loop time with Custom Time Dilation:
This way rifle will fire without slomo.
Updating Gameplay Character
First thing to do is to update GameplayCharacter.
Add new Widget Component named HUD_Aim to character and set UI to HUD_AimLeft. Make sure it’s attached to SprintArm as rest Widgets:
Component Location: (X=-13.665852,Y=19.614624,Z=7.065707)
Component Rotation: (Pitch=0.000075,Yaw=99.999916,Roll=89.999947)
Draw Size: 300 x 100.
Now open Event Graph and add these variables:
Var Name | Var Type | Description |
isAiming | bool | This will tell us if player is currently aiming or not |
AimRate | float | Holds aim interpolation from 0 to 1. Will be used in AnimBlueprint as well to interpolate the hands. |
AimTimeLeft | float – default 6 | How much time left for aiming. |
AimTimeLeftMax | float – defautl 6 | Maximum time that player can aim. |
AnimWidgetActiveLoc | vector | Time information will be in UMG added as widget. We need to hold active and inactive aim widget location. |
AnimWidgetUnactiveLoc | vector | As above. |
bIsAimDeactivated | bool | Aim will be managed in Tick and I need to be sure that this part of Tick won’t be triggered when we don’t have AimTimeLeft. |
RequestAimDeactivation | bool | Before deactivating aim we need to interpolate gun, widget and hands to proper location. |
AnimWidgetActiveLoc: (X=-13.000000,Y=5.000000,Z=11.000000)
AnimWidgetUnactiveLoc: (X=-13.665852,Y=19.614624,Z=7.065707)
Widget location will be interpolated between those two locations.
Now in Event Graph find Begin Play event and in the end update the widget to draw default variables:
Now I want to trigger aim using Right Mouse Button. Input can be found in GameplayCharacter as I was using it for Sniper alternative fire mode:
Make sure to add DisableAim custom event. It should be straightforward. This will manage aim mode toggling and inform UMG.
Now create new custom event named UpdateAim_TimeDilation:
This is handling AimRate (from 0 to 1) to change Camera FOV and later update hands animation in Anim Blueprint. It’s decreasing time left as well and updating UMG widget. Last thing is manage Time Dilations. Aim mode leave Character and Current Weapon with normal time dilation so you can normally shoot and everything else have slomo.
Create new custom event named UpdateAim:
This is actually updating FOV and checking if we have Time Left. If not – call disable aim and when FOV is again at 90 deactivate aim tick.
Now find Tick event and call UpdateAim event:
And that’s all in Character!
Updating Animation Blueprint
Open HeroFPP_AnimationBlueprint and add one float variable named AimingAlpha.
In Event Graph make sure you are getting AimAlpha from Character and set it to AimingAlpha:
This way I don’t need to interpolate the value again. It’s done in Character as it drives FOV as well. I can use the value here as well.
Now in Anim Graph add Transform (modify) Bone node before Final Animation Pose:
So basically when we are aiming b_Root bone location will be increased by 13,0,4 with interpolation.
That’s all!
Creating ShooterTutorial takes a lot of my free time.
If you want you can help me out! I will use your donation to buy better assets packs and you will be added to Credits /Backers page as well. Implementing game is taking time but writing about it is taking much more effort!