Unreal Fest 23: Juice Your Game Mechanics Supplement - Animation Controller and Camera Shake

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
AnimationController320


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

  1. Create a Blueprint from “Camera Shake Source Actor”. Name it BP_CameraShake
  2. Create a Blueprint from “Camera Shake Base”. Name it BP_CameraShakePattern
  3. Open BP_CameraShakePattern
  4. Set Camera Shake Pattern to Perlin Noise Camera Shake Pattern
  5. Set the Location Amplitude Multiplier to 3
  6. Set the Location Frequency Multiplier to 3
  7. Set the Amplitude and Frequency of X, Y and Z to 3
  8. Save
  9. Open BP_CameraShake
  10. Set the Inner and Outer Attenuation Radius to 20000
  11. Set the Camera Shake Base to BP_CameraShakePattern
  12. Add BP_CameraShake to the scene
  13. Create a Level Sequence
  14. Add the Camera Shake BP to the Sequence by dragging the instance of BP_CamerasShake from the outliner, into the sequence.
  15. Press the Plus next to BP_CameraShake in the sequence and select Camera Shake Source Component
  16. Click the Plus next to CameraShakeSourceComponent and add “Camera Shake → Controlled”
  17. Add to a Cinematic Sequence Device
  18. Trigger the sequence as you like!
7 Likes

Amazing talk at UE fest, taught me that the Animation controller in verse and the Animated mesh device are 2 different things :joy:
image

2 Likes

Is there a possibility to smooth out the transition between key frame’s?

Hello. I see this:

 # Animation play modes.
    animation_mode<native><public> := enum:
        # Stop after playing the animation once.
        OneShot
        # Reverse direction after reaching the final `keyframe_delta`, then play the animation in reverse.
        PingPong
        # Play the animation in a loop. This requires the animation ends exactly where it began.
        Loop

How to make spawned async loop to play indefinitely?
Why in the example the loop is wrapped around the AnimateProp() function?