Game logic - Custom controls – Ylands

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "{{Ylands editor navbox}}" to "{{Navbox/Ylands}}")
m (Text replacement - " (={2,})([^ = ])(.*)([^ = ])(={2,}) * " to " $1 $2$3$4 $5 ")
Line 9: Line 9:
[[File:Ylands-Editor-CC-scheme.png|upright=2.0|thumb|center]]
[[File:Ylands-Editor-CC-scheme.png|upright=2.0|thumb|center]]


===Triggers===
=== Triggers ===
Each time player uses any kind of Human Interface Device (keyboard, mouse or mobile device) a trigger is fired. There are two types of triggers - custom and default triggers.
Each time player uses any kind of Human Interface Device (keyboard, mouse or mobile device) a trigger is fired. There are two types of triggers - custom and default triggers.


Line 16: Line 16:
*'''Custom triggers''' - are custom user controls defined only for the purpose of current Custom game, but alone they will do nothing.
*'''Custom triggers''' - are custom user controls defined only for the purpose of current Custom game, but alone they will do nothing.


===Actions===
=== Actions ===
When a trigger is fired (default or custom), in order to take effect a corresponding action has to be fired to actually make any impact on the game.
When a trigger is fired (default or custom), in order to take effect a corresponding action has to be fired to actually make any impact on the game.


Line 26: Line 26:
**In order to have any effect, each custom action has to be scripted via [[Ylands Game logic - Event listener|'''Event Listener''']].
**In order to have any effect, each custom action has to be scripted via [[Ylands Game logic - Event listener|'''Event Listener''']].


===Properties===
=== Properties ===
*'''Active for new player''' - whenever the Controls are active for the player from start.
*'''Active for new player''' - whenever the Controls are active for the player from start.


Line 34: Line 34:
[[File:Ylands-Editor-CC-overview.png|upright=2.0|thumb|center]]
[[File:Ylands-Editor-CC-overview.png|upright=2.0|thumb|center]]


==Default actions + Context==
== Default actions + Context ==
List of default actions. When "Filter by selected context" is checked, all the actions will be filtered according to the selected '''Context'''. In order to disable any default action, just simply un-check the checkbox next to the name of that action.
List of default actions. When "Filter by selected context" is checked, all the actions will be filtered according to the selected '''Context'''. In order to disable any default action, just simply un-check the checkbox next to the name of that action.


===Context===
=== Context ===
Context is a category of controls related to specific control mode, for example when sailing a ship or riding a horse. When selecting a context from drop-down menu, the preview in the middle will change accordingly. Preview allows to check the controls layout and verify whether the control elements are not obstructing each other (mobile only).
Context is a category of controls related to specific control mode, for example when sailing a ship or riding a horse. When selecting a context from drop-down menu, the preview in the middle will change accordingly. Preview allows to check the controls layout and verify whether the control elements are not obstructing each other (mobile only).


==Custom triggers + Custom actions==
== Custom triggers + Custom actions ==
Both custom triggers and custom action can be defined in corresponding tabs.
Both custom triggers and custom action can be defined in corresponding tabs.


===Adding Custom Trigger===
=== Adding Custom Trigger ===
[[File:Ylands-Editor-CC-addbutton.png|upright=1.0|thumb|right|Trigger properties]]
[[File:Ylands-Editor-CC-addbutton.png|upright=1.0|thumb|right|Trigger properties]]


Line 60: Line 60:
**Button foreground - foreground color.
**Button foreground - foreground color.


===Adding Custom Action===
=== Adding Custom Action ===
[[File:Ylands-Editor-CC-addaction.png|upright=1.0|thumb|right|Action properties]]
[[File:Ylands-Editor-CC-addaction.png|upright=1.0|thumb|right|Action properties]]


Line 89: Line 89:
**Default action is disabled if it is disabled at least in one of the active Custom controls.
**Default action is disabled if it is disabled at least in one of the active Custom controls.


===Custom controls===
=== Custom controls ===
Each Custom Action will be represented by corresponding event in the Visual Scripting. Or it is possible to use generic ''On Custom Action''' event and parse the key by its corresponding Action '''Action ID'''.
Each Custom Action will be represented by corresponding event in the Visual Scripting. Or it is possible to use generic ''On Custom Action''' event and parse the key by its corresponding Action '''Action ID'''.


===Event listener===
=== Event listener ===
[[File:Ylands-Editor-CC-eventScript.png|upright=1.0|thumb|right|Scripting]]
[[File:Ylands-Editor-CC-eventScript.png|upright=1.0|thumb|right|Scripting]]


To scripting custom actions from [[Ylands Game logic - Event listener|'''Event Listener''']], set it to listen to '''Player Action''' event '''On Custom Key Action'''. Corresponding Event will be then available in Visual Scripting and can be used. To distinguish between different Custom Actions, '''Action ID''' event parameter can be used. This parameter is corresponding with '''ID''' defined via Controls Manager and it is passed along while the Custom Action is triggered.
To scripting custom actions from [[Ylands Game logic - Event listener|'''Event Listener''']], set it to listen to '''Player Action''' event '''On Custom Key Action'''. Corresponding Event will be then available in Visual Scripting and can be used. To distinguish between different Custom Actions, '''Action ID''' event parameter can be used. This parameter is corresponding with '''ID''' defined via Controls Manager and it is passed along while the Custom Action is triggered.


===Instructions===
=== Instructions ===
Both Default nad Custom Actions can be enabled or disabled in runtime via Visual Scripting.
Both Default nad Custom Actions can be enabled or disabled in runtime via Visual Scripting.



Revision as of 20:08, 31 January 2021

Overview

Custom controls allows the user to customize the controls (i.e key bindings) of a custom game.

  • Custom controls allow to disable any of the default actions.
  • Custom controls allow to define custom triggers and custom actions.
  • Custom controls can be stacked over each other.
  • Custom controls can be shared via comspositions.
Ylands-Editor-CC-scheme.png

Triggers

Each time player uses any kind of Human Interface Device (keyboard, mouse or mobile device) a trigger is fired. There are two types of triggers - custom and default triggers.

  • Default triggers - are default user controls (as defined in game options) which trigger default game actions.
  • Custom triggers - are custom user controls defined only for the purpose of current Custom game, but alone they will do nothing.

Actions

When a trigger is fired (default or custom), in order to take effect a corresponding action has to be fired to actually make any impact on the game.

  • Default actions - are the actual default user actions embedded in the game, such as firing a weapon or driving a car.
    • Can be disabled using the Custom Controls Manager.
  • Custom actions - are actions defined by Game creator.
    • Custom action can use both default or custom triggers to be instigated.
    • In order to have any effect, each custom action has to be scripted via Event Listener.

Properties

  • Active for new player - whenever the Controls are active for the player from start.

Custom Controls

When placed to scene, Custom Controls can be edited by clicking the Edit controls button found in selection properties panel.

Ylands-Editor-CC-overview.png

Default actions + Context

List of default actions. When "Filter by selected context" is checked, all the actions will be filtered according to the selected Context. In order to disable any default action, just simply un-check the checkbox next to the name of that action.

Context

Context is a category of controls related to specific control mode, for example when sailing a ship or riding a horse. When selecting a context from drop-down menu, the preview in the middle will change accordingly. Preview allows to check the controls layout and verify whether the control elements are not obstructing each other (mobile only).

Custom triggers + Custom actions

Both custom triggers and custom action can be defined in corresponding tabs.

Adding Custom Trigger

Trigger properties

It is possible to add new trigger by simply pressing the + button at the end of the trigger list. Any trigger can be then edited by using the properties panel found at the other side of the screen. It is necesarry to define the controls for both PC and mobile. PC is supporting keyboard and mouse. Mobile on other hand does not have these and has to have all the control elements present on the screen in form of buttons.

  • Name - name of the custom trigger.
  • PC properties
    • Default key - the key used for this trigger on PC.
  • Mobile properties
    • Button position - position of the button on mobile device.
    • Sprite - image used for the button.
    • Button text - or text, if no image is used.
    • Button background - background color.
    • Button foreground - foreground color.

Adding Custom Action

Action properties

Actions are managed in same manner as custom triggers. However actions does not have to be always active and can be enabled or disabled via scripting.

  • Active - determines whether the action is active (available) by default.
    • Actions can be enabled / disabled via Visual Scripting using the Get / Set Custom Action instruction.
  • Name - name of the action.
  • ID - internal identifier, used in scripting.
  • Trigger type - haptic requirements of the action.
  • Trigger - allows to select a trigger from the list.
    • Default - available default triggers.
    • Custom - all the custom triggers.
  • PC
    • Show hint - whether to show the hint on players HUD in game.
    • Hint - hint text.

Mobile

    • Hint - text under the button.

Scripting Custom Controls

Custom Actions can be scripted either directly in Custom Controls game logic or via Event Listener.

  • Custom Controls can be a activated using Set Custom Controls Active
  • Active Custom Controls stack on top of each other.
    • Any number of Custom Controls can be enabled (individually for each player).
    • Default action is disabled if it is disabled at least in one of the active Custom controls.

Custom controls

Each Custom Action will be represented by corresponding event in the Visual Scripting. Or it is possible to use generic On Custom Action' event and parse the key by its corresponding Action Action ID.

Event listener

Scripting

To scripting custom actions from Event Listener, set it to listen to Player Action event On Custom Key Action. Corresponding Event will be then available in Visual Scripting and can be used. To distinguish between different Custom Actions, Action ID event parameter can be used. This parameter is corresponding with ID defined via Controls Manager and it is passed along while the Custom Action is triggered.

Instructions

Both Default nad Custom Actions can be enabled or disabled in runtime via Visual Scripting.