Give Page Feedback | API

Execution Controllers - Frame Rate Dependent Controller

The Frame Rate Dependent Execution Controller is designed to keep the current Frame from taking up too much time. ShouldStartExecuting will only return true if the current Frame of the game has not taken more than X seconds (where X is equal to the Frame Time Limit value set in the inspector), or if the Using Component's execution has been suspended for Y Frames (where Y is equal to the Suspension Frame Limit value set in the inspector). Once the Using Component begins/resumes execution, the Controller's ShouldContinueExecuting method returns false once the current Frame has taken more than X seconds (again, where X is equal to the Frame Time Limit value set in the inspector). The time the Using Component has been executing does not factor (different than the other default Execution Controllers).

Creating A Frame Rate Dependent Execution Controller Component

You can add this component by selecting a game object and then selecting from the Top Menu Bar:

Component -> Deep Space Labs -> -> SAM -> Execution Controllers -> Frame Rate Dependent Execution Controller

Adding A Frame Rate Dependent Execution Controller Component From The Top Menu Bar GIF

or by selecting a game object and using the Add Component menu via its inspector:

Component -> Deep Space Labs -> -> SAM -> Execution Controllers -> Frame Rate Dependent Execution Controller

Adding A Frame Rate Dependent Execution Controller Component From Add Component Menu GIF

Frame Time Limit

Used with both ShouldStartExecuting and ShouldContinueExecuting. If the current frame has taken up more than this amount of time (in seconds), ShouldContinueExecuting will return false and ShouldStartExecuting will return false unless the Using Component's execution has been suspended for Y Frames (where Y is equal to the Suspension Frame Limit value set in the inspector).

Suspension Frame Limit

In order to avoid situations where the component using this execution controller would never start executing (or only start executing after a large number of frames) because the frame time is greater than the Frame Time Limit set, this value must be set. Once the component using the execution controller has suspended execution for a number of frames equal to this value, the next query of ShouldStartExecuting will automatically return true.

Assigning The Execution Controller

Currently Execution Controllers can only be assigned to a World's Execution Controller field which resides within the Optional Components window.

Remember that all of the default provided Execution Controllers are only intended to be used with a single World component. If you have multiple Worlds, you will need to assign unique Execution Controller component instances to each one.

Measuring Frame Time

The controller measures frame time by starting a Stopwatch within FixedUpdate. In order for the frame time measurement to be as accurate as possible, the controller should execute before other scripts. The controller script name should automatically be added to the Script Execution Order settings (found in Project Settings), however you may want to confirm this, and if it hasn't been added, add it. Do not place other script files above this controller, unless the script file is also measuring frame time.

Single Instance Per World

Each instance of the Frame Rate Dependent Execution Controller can only be used with a single World!