This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm (Experimental)
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine.Controls Class

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

Enums

TYPE#

NameDescription
CONTROLS_APP = 0A ControlsApp instance.
CONTROLS_DUMMY = 1ControlsDummy instance.
CONTROLS_SIX_AXIS = 2Sixaxis controller as the input device.
CONTROLS_X_PAD360 = 3XBox 360 game pad as the input device.
CONTROLS_JOYSTICK = 4Joystick as the input device.

Properties

float MouseDY#

A screen position change of the mouse pointer along the y axis during the previous frame.
set
Updates a screen position change of the mouse pointer along the Y axis.
set value - Change of the Y-coordinate.

float MouseDX#

A screen position change of the mouse pointer along the x axis during the previous frame.
set
Updates a screen position change of the mouse pointer along the X axis.
set value - Change of the X-coordinate.

string TypeName#

A type name of input controls.

int Type#

The type of input controls.

Members


static Controls ( int type ) #

Creates a smart pointer to Controls.

Arguments

  • int type - Type of the controls to be created.

void 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 GetState ( int state ) #

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

Arguments

  • int state - Control state number. Possible values are in range [STATE_FORWARD;NUM_STATES]. For full list of available controls see Unigine::Controls:: Enumeration at the end of the article.

Return value

1 if the control is pressed; otherwise, 0.

int 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.

bool RestoreState ( Stream stream ) #

Restores controls settings from the stream.

Arguments

  • Stream stream - The stream to save controls data.

Return value

true if the controls settings are restored successfully; otherwise, false.

bool SaveState ( Stream stream ) #

Saves controls settings into the stream.

Arguments

  • Stream stream - The stream to save controls data.

Return value

true if the controls settings are saved successfully; otherwise, false.
Last update: 2020-11-24
Build: ()