Gameplay Events
Contents
- 1 Gameplay Events
- 2 Collectors
- 3 Triggers
- 4 Listening on an event / variable
Gameplay Events
Note : This article handles a complex topic, thus the instructions might not be really clear and coherent, any help or contribution to this page is welcome.
Let's call gameplay events everything that isn't static. In most cases, background is static, lighting is static, objects are staticaly placed on the scene. Dynamically generated content is, for instance, spawning monsters, triggering an animation when entering an area, starting a specific lighting after some time, ... Anything that will happen or not depending on time, player action, variables, etc.
This page aims at showing you the easiest ways to trigger the easiest events, which can be a good start to spice up your mods.
The entities described below are separated into two categories: Collectors and Triggers. Actually, they both list entities that can be actived, and be part of a chain of events. The difference we make here is that Collector entities will most of the time be the initial trigger in the chain (an area, a timer, a lever, ...) whereas Trigger will be activated by a Collector and then take effect on something (an object, a variable).
Collectors
A Collector is an entity that will start a chain of events, for example when the player enters an area, or basically when anything happens. When activated, a collector will send a signal to designated triggers (or even other activate other collector).
PlayerBoxCollectorArea
PlayerBoxCollectorArea is an entity that can be found under the AreaEntity -> CollectorArea -> BoxCollectorArea tree.
Activated by: When the player enters a specific area.
Change the Dimensions of the BoxAreaComponent in the panel "Properties" to suit your needs.
The only other property component you should care about for a basic use of this is the TriggerOtherInstancesComponent. It is detailed in the TriggerMultipleOthersEntity section below.
AIBoxCollectorArea
Same as PlayerBoxCollectorArea but will be activated when an AI enters the area.
Timers
TODO Coming soon.
Levers
Levers can be found under the GameplayEntity -> ItemGameplay -> UsableItem -> LeverUsableItem tree. Let's use for this example a SewersPhysicsLeverusableItem.
Activated by: Player.
TrinePhysicsLeverComponent's properties
- Enabled
- CanBeReused - In case you want your lever to open AND close a door
- OnUseRateVelocity - The speed at which the lever turns (i.e. the ease)
- TriggeringAngle - Angle at which the lever will activate, in degrees. 0 is pointing up
- StartPositionLeft - Reverses the lever so it works from left to right
- LockToEndPosition - Once the lever has been activated, it doesn't come back to its position
- TriggerOnBothEnds
- TriggerOnlyOnce
- OriginalRotationLimitLowAngle - The rotation of the lever the player will find when they arrive
- OriginalRotationLimitHighAngle - The maximum rotation you can pull the lever. Be careful that TriggeringAngle is less
- ReturnToStartRotationDriveVelocity - The speed at which the lever comes back to its original angle if the player lets go
- ReturnToStartVelocityWhenUsingButNotMoving
- TurningAcceleration - Rate at which the player accelerates when using the lever (ease-in factor)
To propagate the event to a trigger, set the TriggerOtherInstancesComponent accordingly. It is detailed in the TriggerMultipleOthersEntity section below.
Triggers
TriggerMultipleOthersEntity
This trigger allows you to propagate a trigger event to multiple other activable entities. It only contains a TriggerOtherInstancesComponent as component, that will propagate the event to a list of activable entities.
Activated by: another Collector / Trigger.
TriggerOtherInstancesComponent's properties
- AllowTrigger
- AllowUnTrigger
- NegateInput - Will negate the input before forwarding it. If the goal is to maintain a door closed until the player arrives, the output should be always true except when the entity is triggered. This can be done by reversing the input
- NegateOutput - The same as NegateInput but happens later in the process. Enabling those two is equivalent to doing nothing
- OtherInstances - A list of instances to propagate the trigger to (i.e. activate them). They can be Triggers but Collectors aswell. To add an instance to the list, click the "+" sign, and look for (or paste) a object or component's GUID. Some activable instances are components, thus not listed in the "All Objects" list, so you'll have to paste their GUID
BreakTriggerEntity
Can be found under the TriggerEntity tree. Will break breakable things. For instance walls that are usually broken with the warrior's hammer.
BreakTriggerComponent's properties
- InstancesToBreak - a list of breakable objects to propagate the trigger to. Add an entry using the "+" sign and select your object in the "..." list
Note : if you don't want the player to be able to mash the item but want only the trigger to do it, check the Immortal property of the TrineHealthComponent of the breakable object.
DeleteTriggerEntity
Can be found under the TriggerEntity tree. Will delete any instance without any animation.
DeleteTriggerComponent's properties
- InstancesToDelete - a list of objects to delete. Add an entry using the "+" sign and select your object in the "..." list
TriggerToBoolPropertyEntity
Can be found under the TriggerEntity tree. When activated, sets a boolean variable.
TriggerToBoolProperyComponent's properties
- Values - A list of possible values for the variable. When the trigger is activated, the variable we take the value of the next element in the list, and so on (and loop). That way you can have 0 1 1 0 as a pattern, for example
- CurrentValueIndex - Do not touch - The index of the currently active value
- InitWithValue
- InitValueIndex - The index of the first value to use
- OutBool - Do not touch - The output value. See "Listening on a variable" section.
TriggerToFloatPropertyEntity
Can be found under the TriggerEntity tree. When activated, sets a float variable.
See TriggerToBoolPropertyEntity.
TriggerToIntPropertyEntity
Can be found under the TriggerEntity tree. When activated, sets a int variable.
See TriggerToBoolPropertyEntity.
TriggerToRotationPropertyEntity
Can be found under the TriggerEntity tree. When activated, sets a three dimensional variable.
See TriggerToBoolPropertyEntity.
TriggerToLuaCallEntity
Will call a Lua Script.
See Lua Scripts
Listening on an event / variable
Now that you have a trigger that changes values on a variable, you'd like to have your objects listen to it. Bascially any property can be linked to any trigger output variable, as long as they are of the same type (see Variable Types. This coul be useful to:
- Enable a timer (by liking its Enabled property to a boolean trigger)
- Start an animation
- Rotate an object
- Chain triggers
- Anything that relies on a variable
Now, the following example includes a PlayerBoxCollectorArea, that triggers a TriggerToRotationEntity, that has two possible values ((0,0,0) and (0,0,90°)). We will now connect the Rotation output to an object's Rotation property (that can be found in its TransformComponent component in the properties panel). What you should do is:
- Get to the TriggerToRotationPropertyComponent properties panel
- Right click on the OutRotation property (note that it's the same procedure with other triggers and types, except you will have names like OutBool, OutInt, OutValue, ...)
- Select "Select property as input"
- Go to the TransformComponent properties panel of the desired object
- Right click on the Rotation property
- Select "Connect input to this property directly"
You should now see a PropertyConnectionComponent appear, and, provided the BoxCollecterArea and the trigger are properly configured, an object that spins when you enter the area. This procedure is the same for any property of any object.
--LeonardA-L (talk) 11:34, 7 March 2015 (UTC)