Game Command Handler Sub-Types
Checked with version: 2018.1
The following subsections are specialised components which have the Game Command Handler functionality, and list extra fields that are used in addition to the common Game Command Handler fields.
Use this component to control platforms that move on predictable paths. Find it in the Project window in Prefabs > Interactables. For details on this type of Game Command Handler, see the tutorial page on moving platforms.
Interact On Trigger Health Crates
A good use case example of an Interact On Trigger is the Health Crate prefab, which increases the player’s health when the player damages it. Find it in the Project window in Prefabs > Interactables. The HealthCrate prefab uses the Interact On Trigger script:
When first instantiated, one of the events in the Interact On Trigger script is missing. On this event, the player needs to be told its health is getting reset. To do this, select Ellen from the scene as the GameObject to call a function on. Then from the function drop-down menu, select Damageable > ResetDamage().
Now, whenever Ellen bumps into the Health Crate in the scene, her health will reset to full.
Trigger Unity Event
This class calls a Unity Event when the command is sent.
- Unity Event: The event to call when the command is sent.
Toggle Game Object Active
This class switches the active state of a collection of GameObjects. If each GameObject is active, then it switches to inactive; if each is inactive, then it switches to active.
- Targets: The collection of GameObjects to have their active state switched.
This class changes the appearance of a GameObject by cycling the material of its renderer.
This command is a GameCommandReceiver, which switches materials on the target object. Each time the command is received, the next material in the materials list is applied. When the last material is reached, the first material will be used as the next material.
Target: The Renderer that will have its material cycled.
Materials: The Materials to cycle through. The material at index 0 should be the default material of the renderer. This is because the first time a command is handled, the material at index 1 is used.
Start Playable Director
This class starts a Timeline when a command is handled. It also has events that are called when the Timeline starts and finishes playing.
Director: The Playable Director that references the Timeline to be played.
On Director Play: The event that is called just before the Timeline starts playing.
On Director Finish: The event that is called just after the Timeline finishes. This works using a timed Invoke. If something changes the duration of the timeline or pauses it without changing the Time.timeScale then the event might not coincide with the end of the Timeline.
This class rotates a GameObject when using an animation seems like overkill. This command is a GameCommandReceiver. When the specified command is received, it will perform a rotation on the transform.
Loop Type: Default Setting: Once This controls what the GameObject does when the full duration has been reached.
Once The rotation will not repeat.
PingPong The GameObject will rotate back and forth around its axis.
Repeat The GameObject will restart from the beginning each time it reaches its duration.
Duration: Default Setting: 1 The length of time in seconds to perform the rotation.
Accel Curve: How the rotation speed varies over time.
Activate: Default Setting: false Whether the command has been received and the GameObject is currently rotating.
On Start Command: The command to send when the rotation starts.
On Stop Command: The command to send when the rotation finishes.
On Start Audio: The audio to play when the rotation starts.
On Stop Audio: The audio to play when the rotation stops.
Preview Position: Start previewing the behaviour of the component at the specified position.
Axis: Default Setting: (0, 0, 1) The axis in local space around which the GameObject will rotate.
Start: Default Setting: 0 The number of degrees around the axis at which the GameObject will start its rotation.
End: Default Setting: 90 The number of degrees around the axis at which the GameObject will end its rotation.
This class moves a GameObject’s rigidbody from a specified Start position to a specified End position. This command is a GameCommandReceiver. When the specified command is received, it will perform a translation on the transform.
The following image shows a GameCommandReceiver. The Recv Open label is telling us that this GameObject will react when a Open command is received. The white arrows show the direction of the incoming command.
Loop Type: Default Setting: Once This controls what the GameObject does the full duration has been reached.
Once The movement will not repeat.
PingPong The GameObject will move back and forth along its path.
Repeat The GameObject will restart from the beginning each time it reaches its duration.
Duration: Default Setting: 1 The length of time in seconds to perform the movement.
Accel Curve: How the speed varies over time.
Activate: Default Setting: false Whether the command has been received and the GameObject is currently moving.
On Start Command: The command to send when movement starts.
On Stop Command: The command to send when movement finishes.
On Start Audio: The audio to play when movement starts.
On Stop Audio: The audio to play when movement stops.
Rigidbody: The rigidbody component of the GameObject to move. The rigidbody to move should not be on the same GameObject as this script. Generally, the rigidbody would be a child of this script's GameObject. The rigidbody will be moved relative to this script's GameObject.
Start: Default Setting: (0, 0, -1) The position in local space that the rigidbody will start to move.
End: Default Setting: (0, 0, 1) The position in local space that the rigidbody will stop moving.
Set GameObject Active
This class works similarly to the ToggleGameObjectActive class except instead of switching back and forth, the active state of each GameObject is set to the same value.
Targets: The GameObjects to have their active state set.
Is Enabled Default Setting: true The active state that the target GameObjects will be set to.
Set Animator Trigger
This class sets an Animator trigger parameter when a command is received.
Animator: The Animator component to set the trigger parameter on.
Trigger Name: The name of the trigger parameter to set.
This class simply calls the Respawn function of the Player Controller. This will cause the scene to fade out and Ellen to be taken back to the last checkpoint.
- Player: Reference to the PlayerController script on Ellen.
This class plays the audio clips assigned to a collection of audio sources. The audio sources need to be set up separately.
- Audio Sources: The sources to play when a command is received.
This class plays the animation clips assigned to a collection of animation components. The animation components themselves need to be set up separately.
- Animations: The animation components to have their animations played when a command is received.
Particle System Emit
This class causes a collection of particle systems to each emit a specified number of particles.
Particle Systems: The particle systems to emit particles when a command is received.
Count: The number of particles to be emitted by each particle system.
This class works slightly differently from other GameCommandHandlers. It is instead an intermediary step when something needs to happen multiple times before the command is handled. It works by counting the number of times the selected command is received and, when the required count is reached, a designated GameCommandHandler performs its interaction.
Current Count: Default Setting: 0 How many commands have been received so far.
Target Count:: Default Setting: 3 How many commands are required before the GameCommandHandler performs its interaction.
On Increment Send Command: An optional command that can be sent whenever the count is incremented. The command is not be sent when the Target Count is reached.
On Increment Perform Action: An optional handler that can perform its action whenever the count is incremented. The action is not be performed when the Target Count is reached.
On Target Reached Send Command: An optional command that can be sent when the Target Count is reached.
On Target Reached Perform Action: An optional handler that can perform its action when the Target Count is reached.
Simple FX Synth
The SimpleFXSynth component is used to generate AudioClips for game sound effects.
Fx Name When in Play mode, the Fx Name field is used to share the AudioClip among all SimpleFXSynth instances. This means each unique sound effect should have a unique Fx Name.
Duration: Controls the length, in seconds, of the AudioClip.
Layers: A stack of SynthLayer objects. Each SynthLayer object has an oscillator, with frequency and volume envelopes that are applied over the duration of the AudioClip. Output from the oscillator is fed into a filter which has cutoff and resonance envelopes that are also applied over the duration of the AudioClip.
Audio: The Audio Source that will play the AudioClip.