This forum post is a supplement to the Unreal Fest 23 talk:
Practical Polish: Secrets of How to “Juice” Your Game Mechanics in UEFN
Link: < Will be updated when video is live >
This post contains code sample for Animation Controller in Verse as well as walkthrough for Camera Shake.
Animation Controller
Code sample for how to use the Animation Controller
using { /Fortnite.com/Devices }
using { /Fortnite.com/Devices/CreativeAnimation }
using { /Fortnite.com/Devices/CreativeAnimation/InterpolationTypes }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }
AnimationControllerExample := class(creative_device):
@editable
PropToAnimate : creative_prop = creative_prop {}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
loop:
AnimateProp()
AnimateProp()<suspends> : void =
# This is the movement keyframe data
# It is the amount of location, rotation and scale you want to change
# This change is additive
# It will occur over the time specified and interpolate via the Interpolation method specified
MovementKeyFrame: keyframe_delta = keyframe_delta
{
# Move our prop, 200 cm in the X direction
DeltaLocation := vector3 { X:=200.0, Y:=1.0, Z:=1.0 }
# Rotate the object 90 degrees about the Z (Yaw)
DeltaRotation := MakeRotationFromYawPitchRollDegrees(90.0, 0.0, 0.0)
# Do not change scale
DeltaScale := vector3 { X:=1.0, Y:=1.0, Z:=1.0 }
# Animate over 0.5 seconds
Time := 0.5
# Use EaseOut interpolation
Interpolation := EaseOut
}
if (AController := PropToAnimate.GetAnimationController[]):
# Make an array of the keyframes
FortVaderKeyFrames:[]keyframe_delta = array { MovementKeyFrame }
# Set the animation to play
AController.SetAnimation(FortVaderKeyFrames, ?Mode:=animation_mode.OneShot)
# Play the animation
AController.Play()
# Wait 2.0 seconds before looping
Sleep(2.0)
Camera Shake
- Create a Blueprint from “Camera Shake Source Actor”. Name it BP_CameraShake
- Create a Blueprint from “Camera Shake Base”. Name it BP_CameraShakePattern
- Open BP_CameraShakePattern
- Set Camera Shake Pattern to Perlin Noise Camera Shake Pattern
- Set the Location Amplitude Multiplier to 3
- Set the Location Frequency Multiplier to 3
- Set the Amplitude and Frequency of X, Y and Z to 3
- Save
- Open BP_CameraShake
- Set the Inner and Outer Attenuation Radius to 20000
- Set the Camera Shake Base to BP_CameraShakePattern
- Add BP_CameraShake to the scene
- Create a Level Sequence
- Add the Camera Shake BP to the Sequence by dragging the instance of BP_CamerasShake from the outliner, into the sequence.
- Press the Plus next to BP_CameraShake in the sequence and select Camera Shake Source Component
- Click the Plus next to CameraShakeSourceComponent and add “Camera Shake → Controlled”
- Add to a Cinematic Sequence Device
- Trigger the sequence as you like!