This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Animations-Related Classes
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
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы

Unigine::ControlsDummy Class

Header: #include <UnigineControls.h>
Inherits from: Controls

This class is used to create controls for players that should not be controlled by the user (for example, when such a player is controlled by an AI). This class allows to create any other completely custom implementation of controls.

The code below shows how to create custom controls and toggle showing the item inventory when 'i' key is pressed on the keyboard. For that, auxiliary state STATE_AUX_0 is used.

Source code (C++)
#include "AppWorldLogic.h"
#include <UnigineControls.h>

using namespace Unigine;
// ...

ControlsDummyPtr my_controls = ControlsDummy::create(); // custom controls
bool inventory_toggled = false; // show item inventory toggle

void update_input(ControlsPtr controls) {
	// Check if the key is pressed and update the state of the specified control.
	controls->setState(Controls::STATE_AUX_0, Input::isKeyPressed(Input::KEY_I));
}

// Implement your game logic for showing or hiding item inventory.
void update_game_logic(ControlsPtr controls) {
	// If the control state is positive (the key has been pressed), toggle item
	// inventory on and off.
	if (controls->getState(Controls::STATE_AUX_0)) {
		inventory_toggled = !inventory_toggled;
	}
}

/*
 */
 // Update controls each frame according to the user input.

int AppWorldLogic::update()
{
	update_input(my_controls);
	update_game_logic(my_controls);

	return 1;
}

ControlsDummy Class

Members


static ControlsDummyPtr create ( ) #

Constructor. Creates a new set of dummy controls.
Last update: 28.02.2023
Build: ()