text
stringlengths
0
17.2k
Finally, in TG_PostUpdateWork, the laser particle effect would be updated with the final locations of both the aiming actor and the reticule.
Tick dependency can be used to eliminate the need for TG_PostUpdateWork. The laser particle can be placed in TG_PostPhysics along with the reticule actor, using tick dependency to ensure that the laser is updated with the reticule's location only after the reticule has had a chance to tick. By setting the laser's tick dependency to the reticule, we can ensure that the laser isn't updated too early, but without waiting for other post-physics ticks that aren't relevant. This can be more efficient than moving the laser into a different tick group.
As an example of a case that would not benefit from tick dependency, the reticule itself does not need to be tick-dependent on the aiming actor, even though it needs the aiming actor to have finished ticking before it can do its own tick. The reason that tick dependency is unnecessary is that the reticule is in post-physics while the aiming actor is in pre-physics. Because they're in different tick groups, we can be assured that they will always run in the order of the groups themselves, since each tick group completes ticking all of its actors and components before the next tick group can begin.
In BeginPlay, an actor will register its primary tick function and the tick functions of its components with the engine. An actor's tick function can be set to run in a specific tick group, or disabled entirely, via the PrimaryActorTick member. This is generally done in the constructor to ensure that the data is set correctly before BeginPlay is called. Some commonly-used code follows:
Just as Actors can be segregated into different ticking groups, so can Components. Previously, an Actor ticked all of its Components during the Actor's tick. This still happens, but Components that need to be in different groups are added to a list that manages when they will be ticked. Components should be assigned ticking groups using the same criteria for assigning an Actor to a tick group. The tick structure for Components is named differently from the one that Actors use, but it works the same way:
Remember that PrimaryActorTick uses the Actor's Tick() function, while PrimaryComponentTick uses the ActorComponent's TickComponent() function.
The default tick function for an actor or component can be enabled or disabled during the game with the AActor::SetActorTickEnabled and UActorComponent::SetComponentTickEnabled functions, respectively. In addition, an actor or component can have multiple tick functions. This is accomplished by creating a struct that inherits from FTickFunction and overriding the ExecuteTick and DiagnosticMessage functions. The default actor and component tick function structures are good examples of how to build your own, and can be found in EngineBaseTypes.h under the names FActorTickFunction and FComponentTickFunction.
Ticking
Tick Groups
Tick Dependency
Examples
Actor Spawning
Component Ticking
Advanced Ticking Functionality
Tick Group Order
Tick Group/Tick Dependency Usage Example
TG_PrePhysics
Beginning of the frame.
TG_DuringPhysics
Physics simulation has begun by the time this step is reached. Simulation may finish and update the engine's physics data at any time while ticking this group, or after all group members have ticked.
TG_PostPhysics
Physics simulation is complete and the engine is using the current frame's data by the time this step begins.
n/a
Process latent actions, tick the world timer manager, update cameras, update level streaming volumes and streaming operations.
TG_PostUpdateWork
n/a
n/a
Handle deferred spawning of actors created earlier in the frame. Finish the frame and render.
Code Example:
PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bTickEvenWhenPaused = true; PrimaryActorTick.TickGroup = TG_PrePhysics;
Code Example:
PrimaryComponentTick.bCanEverTick = true; PrimaryComponentTick.bTickEvenWhenPaused = true; PrimaryComponentTick.TickGroup = TG_PrePhysics;
Remarks
Once you have added your own tick function structure to your actor or component, it can be initialized, usually in the constructor of the owning class. To enable and register the tick function, the most common route is overridingAActor::RegisterActorTickFunctionsand adding calls to the tick function structure'sSetTickFunctionEnable, followed byRegisterTickFunctionwith the owning actor's level as an argument. The end result of this process is that any actor or component that you create can tick multiple times, including ticking in different groups and with individual dependencies per tick function. To set a tick dependency manually, callAddPrerequisiteon the tick function structure you want to make dependent on another and pass in the tick function structure that you wish to use as your dependency.
Animation Modifiers
Animation Modifiers (Anim Modifier) are a type of native or Blueprint Class that enable users to apply a sequence of actions to an Animation Sequence or Skeleton asset. An example of this includes (but is not limited to) creating automatic foot sync markers by pin-pointing on which frames the right or left foot is place on the ground. Using this information, Animation Sync Markers can be added to frames where a foot bone is at its lowest point (or touching the floor).
Above an Anim Modifier is used to generate auto foot sync markers.
Accessing and applying Anim Modifiers is performed in either the Animation Editor or Skeleton Editor under the Animation Data tab. When applying an Anim Modifier to a Skeleton, the modifier is applied to all Animation Sequences that are based on the Skeleton. When applying the modifier to an Animation Sequence, it is only applied to the sequence itself and no other sequences.
To get started, you will need to create an Anim Modifier Blueprint class:
In your project's Content Browser, click the Add New button and select Blueprint Class.
In the Pick Parent Class window, expand All Classes and search for and select Animation Modifier, click Select then give it a name.
Double-click the new Animation Modifier Blueprint to open it up in the Blueprint Editor.
With your Anim Modifier created, you can now use Blueprint Script and functions contained with the Animation Blueprint Library to access and manipulate animation data.
Right-click in the graph of the Anim Modifier Blueprint to see the context menu and list of functions available, particularly under the Animation Blueprint Library.
In the image above, functions related to Marker Syncing are expanded which enable you to synchronize animations using marker data.
Before working with the various functions available for accessing data, you will want to implement the OnApply and OnRevert events. The OnApply Event enables the user to change, add or remove data from the animation while the OnRevert enables the user to remove previously applied user changes (or return the sequence to its original state). Each event returns the Animation Sequence in which to feed the Animation Blueprint Library operations.
In the image above, when the Anim Modifier is applied, a new Notify track is created with the defined name while reverting the Anim Modifier, the track is removed.
Implementing an Anim Modifier can be done inside a Skeleton asset (to add to the Anim Modifier to all animations associated with the Skeleton) or in a single Animation Sequence.
Inside the Skeleton Editor or Animation Editor, go to Window menu option and select Animation Data Modifiers.
In the Animation Data Modifiers tab, select Add Modifier and select your desired Anim Modifier Blueprint.