Ylands Game logic - Custom controls
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.
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.
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.
- Active for new player - whenever the Controls are active for the player from start.
When placed to scene, Custom Controls can be edited by clicking the Edit controls button found in selection properties panel.
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 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
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
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.
- Show hint - whether to show the hint on players HUD in game.
- Hint - hint text.
- 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.
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.
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.
Both Default nad Custom Actions can be enabled or disabled in runtime via Visual Scripting.