This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

engine.controls Functions

Warning
UnigineScript is deprecated and will be removed in future releases. Please consider using C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt is not guaranteed, as the current level of support assumes only fixing critical issues.

Handles input from the user (keyboard, mouse, joystick or gamepad). It can be used instead of the default engine.controls in one of the two possible ways:

  1. In case you need custom input handling (by AI, for example), you can implement your own controls via ControlsDummy.
  2. You can get the current application controls (i.e. the instance of the default engine controls) via engine.getControls(). After that, you control user input using methods of Controls class exactly the same way as via engine.controls functions.

    Such approach, for example, allows to switch between user-controlled input (Controls) and AI-controlled input (ControlsDummy) without having to change the game logic.

    Source code (UnigineScript)
    // Get the instance of default engine controls
    Controls controls = engine.getControls();
    controls.setMouseDX(5);

    Here, the function Controls::setMouseDX() does the same as engine.controls.setMouseDX().

The following set of functions is used to register actions (i.e. controls states) that will be executed on the provided input and bind them to specified input events. The actual meaning of all controls registered with CONTROLS_STATE_* variables (for example, CONTROLS_STATE_JUMP or CONTROLS_STATE_FIRE) is defined manually in script by the programmer who uses them. (See how to map controls states and keys).

See Also#

Controls Class

Members


void engine.controls.setMouseDX ( float mousedx ) #

Updates a screen position change of the mouse pointer along the X axis.

Arguments

  • float mousedx - Change of the X-coordinate.

float engine.controls.getMouseDX ( ) #

Returns a screen position change of the mouse pointer along the X axis during the previous frame.

Return value

Change of the X-coordinate.

void engine.controls.setMouseDY ( float mousedy ) #

Updates a screen position change of the mouse pointer along the Y axis.

Arguments

  • float mousedy - Change of the Y-coordinate.

float engine.controls.getMouseDY ( ) #

Returns a screen position change of the mouse pointer along the Y axis during the previous frame.

Return value

Change of the Y-coordinate.

void engine.controls.setState ( int state, int value ) #

Toggles the state of the given control on or off.

Arguments

  • int state - State (one of CONTROLS_STATE_* variables).
  • int value - Positive value to "press" the corresponding control; 0 to release it.

int engine.controls.getState ( int state ) #

Returns the state of a given control (pressed or unpressed).

Arguments

Return value

1 if the control is pressed; otherwise, 0.

int engine.controls.getType ( ) #

Returns the type of input controls.

Return value

Controls type (one of CONTROLS_* variables):
  1. CONTROLS_APP = 0
  2. CONTROLS_DUMMY
  3. CONTROLS_SIX_AXIS
  4. CONTROLS_X_PAD360
  5. CONTROLS_JOYSTICK

string engine.controls.getTypeName ( ) #

Returns a type name of input controls.

Return value

Type name.

int engine.controls.clearState ( int state ) #

Returns a control state and clears it to 0 (not pressed). This function allows to handle control only once even if it is kept pressed over several frames.

Arguments

Return value

Returns the state of the given control: 1 if the control is pressed; otherwise,0.

int engine.controls.restoreState ( Stream stream ) #

Restores controls settings from the stream.
Warning
This function is deprecated and will be removed in the next release.

Arguments

  • Stream stream - The stream to save controls data.

Return value

1 if the controls settings are restored successfully; otherwise, 0.

int engine.controls.saveState ( Stream stream ) #

Saves controls settings into the stream.
Warning
This function is deprecated and will be removed in the next release.

Arguments

  • Stream stream - The stream to save controls data.

Return value

1 if the controls settings are saved successfully; otherwise, 0.
Last update: 2020-04-10
Build: ()