TICK OPTIMIZATION TOOLKIT

Description

Tick Optimization Toolkit optimizes ticks in actors, components, and timelines by reducing their frequency or disabling them with distance and visibility. All the features are easily accessible from BlueprintsNo C++ knowledge is needed.

No more need for spawning and despawning actors that would otherwise fit into memory. No more juggling of triggers and volumes that above all obfuscate your levels in the editor. With Tick Optimization Toolkit, you can gain precious milliseconds of game thread time with ease.

For some concrete numbers, you can look into the example. Results on my machine are:

  • for 1024 AI Characters from 9 FPS (108 ms) to 55 FPS (18 ms)
  • for 4096 Environment Actors from 20 FPS (48 ms) to 80-220 FPS (4 ms, GPU bound)

Features

  • Optimizes everything that ticks in an actor: components, timelines, and the actor itself.
  • Can handle thousands of actors with ease.
  • Works with any actor: pawn, controller, projectile, moving, stationary, etc. 
  • Can easily be incorporated into an existing project.
  • Supports multiplayer: local, online (with listen or dedicated server).
  • All the features are easily accessible from Blueprints and C++.
  • Additionally, exposes animation update rate optimizations to blueprints.

Gallery

Downloads

Example project:

Video Tutorials

Documentation

Introduction

Tick Optimization Toolkit plugin allows you to scale the ticking frequency of an actor based on its distance to the player and its visibility. For each actor you want to optimize, you can configure multiple zones that, with increasing distance, will increase the tick interval and possibly disable ticking all together in the most distant zone. This way, you can have thousands of ticking actors on your scene and pay the cost of ticking just a fraction of them each frame.

Basic usage

Enable Plugin

To use Tick Optimization Toolkit plugin, you have to enable it first:

  1. Open the ‘Plugins’ window. You can do this through the ‘Edit’ menu in the menu bar.
  2. In the navigation panel, on the right side of the window, select the ‘Gameplay’ group from the ‘Installed’ section.
  3. In the list of plugins, on the left side of the window, find the ‘Tick Optimization Toolkit’ plugin.
  4. Make sure that the plugin is marked as ‘Enabled’. You will have to restart the editor for this change to take effect.

Setup Player

For the plugin to know of the player, you have to attach an optimization focus component to it. In most cases, the best place for this will be the camera component in the player’s pawn.

  1. Open blueprint of the player’s pawn.
  2. Select a camera component.
  3. Press the ‘Add Component’ button.
  4. In the search box, type ‘tick opt’.
  5. From the components list, select the ‘Tick Opt Toolkit Focus’ component.
  6. Save the blueprint.

Setup Basic Actor Optimizations

For most actors, you will need to attach a single optimization target component and configure tick optimization zones. You want to attach the target component to a component, which represents the position of the actor (the root component in most cases):

  1. Open blueprint of the actor.
  2. Select the appropriate component (possibly the root component).
  3. Press the ‘Add Component’ button.
  4. In the search box, type ‘tick opt’.
  5. From the components list, select the ‘Tick Opt Toolkit Target’ component.
  6. Save the blueprint.

At this point, your actor and all its components and timelines will tick only in a 10m radius from the player.

Customize Actor Optimizations

Settings

The basic settings will work fine in some cases, but the target component is highly customizable and allows for much greater control over ticking. Below you can see the configuration used for one of the actors in the example project. In the viewport, you can see the visualization of sphere distance zones used in this example.

The available settings are:

Distance Mode

This is a mode with which the distance to the focus (player) is determined. It has the following settings:

  • Sphere – the basic mode in which the distance is determined by a sphere with a given ‘Radius’.
  • Box – the mode in which the distance is determined by Z-axis aligned box with given ‘Extents’ (distances from the center of the box to its walls on each of XYZ axes) and ‘Rotation’ around the Z-axis.
  • None – the mode in which the distance is not taken into account.
Buffer Size

The buffer is used to mitigate the issue with an actor being exactly at the distance at which the optimization kicks in and it switches rapidly between states. The distance is extended by the buffer size if the player is inside. If the player exceeds the distance, it has to traverse this additional buffer to get back inside.

Mid Zone Sizes

These are additional optimization zones between inner and outer zones. If we’re using a sphere with a radius of 10m, and three mid zones 10m each, we get 5 zones: 0-10m, 20-30m, 30-40m, and +40m. For each of the zones, we can have different tick settings.

Visibility Mode

This is a mode with which the visibility of the actor is determined. It has the following settings:

  • Front – the mode in which everything in front of the focus (player) is deemed visible. This is very fast to calculate and basically can cut the ticks overhead in half.
  • Rendered – the mode in which the actor is deemed visible if it has been rendered in the previous frame. This is more accurate but also more costly.
  • None – the mode in which the visibility is not taken into account.
Actor Tick Control

If checked, the owning actor’s tick will be automatically controlled with the tick settings (look below).

Components Tick Control

If checked, all the components that were present in the actor before BeginPlay will have their ticks controlled with the tick settings. This includes components added with blueprint editor and construction script but excludes components added in and after the BeginPlay event.

Timelines Tick Control

If checked, all the timelines in the actor will have their ticks controlled with the tick settings.

Sync Timelines to World

If checked, all the timelines will be synced to the world time. In the effect, timelines that are not ticking (are out of range or hidden) will register the passage of time and it will be impossible to perceive that they were paused. The side effect will be, that all the instances of the actor will be synchronized.

This works only for looping timelines.

Force Execute First Tick

If checked, all the ticks controlled by the target component will be fired on the first frame after BeginPlay.

Tick Settings

This is an array of settings used for each combination of distance zone and visibility state of the actor. Each row is a distance zone ordered from the most inner to the most outer. For each zone, there are four setting columns:

  1. ‘Tick Enabled’ when Visible.
  2. ‘Tick Interval’ when Visible.
  3. ‘Tick Enabled’ when Hidden.
  4. ‘Tick Interval’ when Hidden.

The ‘Tick Interval’ is in seconds, meaning an interval of 0.05 will fire 20 ticks per second, and 0.2 will fire only 5. The value of 0.0 means that the tick will fire every frame.

Events

You can further customize actor behavior depending on its distance zone and visibility state using events.

On Tick Changed

Triggered when distance zone and/or visibility state of the actor changes. Its outputs are:

  1. Zone Changed – true if distance zone did change.
  2. Visibility Changed – true if visibility state did change.
  3. Zone – current distance zone.
  4. Visible – current visibility state.
On Tick Zone Changed

Triggered when distance zone changes. It outputs the current distance zone.

On Tick Visibility Changed

Triggered when visibility state changes. It outputs the current visibility state.

On Tick Enabled Changed

Triggered when the tick of the actor or any of its components or timelines is controlled with tick settings and the tick is enabled/disabled. It outputs the current state of the tick.

Functions

If you need finer control of the components and timelines that should have their tick controlled, you can use the following functions:

Add Component Tick Control

Can be used to manually add components to tick control, e.g. in the case when the ‘Components Tick Control’ flag is disabled or when the component is constructed in or after the BeginPlay event.

Should be called in or after BeginPlay event.

Remove Component Tick Control

Can be used to remove components from tick control, e.g. in the case when the ‘Components Tick Control’ flag is enabled but the component’s tick should not be controlled or when the component is about to be destroyed.

Should be called in or after BeginPlay event.

Add Timeline Tick Control

Can be used to manually add timelines to tick control, e.g. in the case when the ‘Timelines Tick Control’ flag is disabled. Additionally to the timeline, it takes as an input ‘Sync to World’ flag that works the same as ‘Sync Timelines to World’ property, but only in the context of the one added timeline.

Should be called in or after BeginPlay event.

Remove Timeline Tick Control

Can be used to remove timelines from tick control, e.g. in the case when the ‘Timelines Tick Control’ flag is enabled but the timeline’s tick should not be controlled.

Should be called in or after BeginPlay event.

Force

There’s an additional feature that allows you to force a set state of zone distance and visibility mode. This can be useful to force a particular actor instance to tick every frame or be disabled regardless of its distance to the player.

For this, you can use a set of advanced properties (to make the actor forced by default) or functions.

Properties

In the advanced section of properties, you have a flag ‘Forced’ that, if enabled, will make the actor force by default. The ‘Tick Zone’ and ‘Tick Visible’ properties will in this case be used as the set state unimpacted by the true distance and visibility.

The ‘Tick Zone’ property will be clamped to the appropriate zones range.

Functions

You can use the ‘Force’ function to set the forced state of your choosing, and the ‘Release’ function to release the forced state and return the target component to the normal operation.

The ‘In Zone’ input will be clamped to the appropriate zones range.

Multiplayer Support

The system does not interfere with the replication, nor needs to be replicated itself. One thing that is taken into consideration is the possibility of multiple optimization focuses (players). This case is handled differently depending on the net mode:

  • Listen/Dedicated Server – all the focuses are taken into account.
  • Client/Standalone – only focuses with a local net owner are taken into account.

When there are multiple focuses taken into account, the system works as follows:

  • Distance Zone – calculated based on the closest focus.
  • Visibility State – visible if any focus can see the actor.

‘Rendered’ Visibility Mode

‘Rendered’ visibility mode should be used only in standalone games and local multiplayer. The server does not know when an actor is rendered on the client.

Custom Support for Multiple Focuses

If you would like to change the way multiple focuses are handled in a multiplayer game (or maybe some other situation), you can create a child component of the ‘Focus Component’ and override the ‘Should Track’ function. The function is evaluated for each frame for each focus, and if it returns ‘true’, the focus is taken into account in the calculations.

Animation Update Rate Optimizations

Animation Update Rate Optimizations is an Unreal Engine 4 feature, mentioned in Animation Optimization section of the UE4 documentation. This feature works similarly to the way the rest of this plugin works, but only for animated skinned/skeletal mesh components. It not only reduces the rate at which skinned/skeletal mesh animations are updated (ticked) but also allows for interpolation between frames and properly handles things like root motion. On the other hand, it uses the actor’s screen size instead of its distance from the player to determine the update rate, which can be less intuitive.

The Animation Update Rate Optimizations can be used in conjunction with the focus/target components pair. It can produce a better-looking result for skinned/skeletal mesh animations, than using only the target component.

However, depending on the needs, the target component can be used on its own, even on skinned/skeletal mesh components.

Setup Update Rate Optimizations

The Update Rate Optimizations are controlled using a separate component. To add the component:

  1. Open blueprint of the actor with a skinned/skeletal mesh component.
  2. Press the ‘Add Component’ button.
  3. In the search box, type ‘tick opt’.
  4. From the components list, select the ‘Tick Opt Toolkit Anim Update Rate Opt’ component.
  5. Save the blueprint.

Settings

Anim Update Rate Optimizations Mode

The mode in which the number of skipped frames is determined. It has the following settings:

  • Screen Size – uses relative screen size (1.0 means full screen) based on the bounding sphere and smaller screen dimension.
  • LOD – uses currently used LOD of the skinned/skeletal mesh component.
  • MinLOD – uses minimal LOD of the skinned/skeletal mesh component.
Frames Skipped Screen Size Thresholds

The mapping used to calculate the number of skipped frames in ‘Screen Size’ mode. The index in the array is the number of skipped frames and the value is the lower limit of the screen size that allows for this number of skipped frames.

LOD to Frames Skipped

The mapping used to calculate the number of skipped frames in ‘LOD’ and ‘MinLOD’ modes. The index is the LOD and the value is the number of skipped frames to use for the LOD.

Non Rendered Frames Skipped

The number of skipped frames when the skinned/skeletal mesh has not been rendered in the previous frame.

Max Frames Skipped for Interpolation

The maximum number of skipped frames allowing for frame interpolation. If the number of skipped frames is greater, the previously calculated frame will be used.

Force Enable Anim Update Rate Optimizations

If checked, will enable Update Rate Optimizations in every skinned/skeletal mesh component in the actor. Normally, this optimization has to be enabled manually for each component. This property allows for doing this in one place.

Functions

Register Dynamic Skinned Mesh Component

Register skinned/skeletal mesh component that has been created in or after BeginPlay event. This function obeys the ‘Force Enable Anim Update Rate Optimizations’ flag, and if the flag is checked it will enable optimizations on the registered component.

This function MUST be called for every skinned/skeletal component created dynamically, even if the component won’t have the Update Rate Optimizations enabled.

Comments

Your email address will not be published. Required fields are marked *

Scroll to top