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
Controls-Related Classes
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
Учебные материалы

Физический триггер (Physical Trigger)

The Physical Trigger is an object that triggers events when physical objects get inside or outside of it. There are 4 types of physical triggers based on their shape:Physical Trigger - это объект, выполняющий функции обратного вызова, когда физические объекты попадают внутрь или за пределы него. В зависимости от формы существует 4 типа физических триггеров:

  • Sphere trigger of the specified radiusСферический триггер указанного радиуса
  • Capsule trigger of the specified radius and heightКапсульный триггер указанного радиуса и высоты
  • Cylinder trigger of the specified radius and heightЦилиндрический триггер указанного радиуса и высоты
  • Box trigger of the specified size along the axesТриггер в форме куба заданного размера по осям

To be detected by the trigger, a physical object must have both a physical body (with the Physical mask that matches the Physical mask of the trigger) and a shape (with the Collision mask that matches the Collision mask of the trigger).Для обнаружения срабатывания триггера физический объект должен иметь как физическое тело (с маской Physical, которая соответствует маске Physical триггера) и коллизионную форму (с маской Collision, которая соответствует маске Collision триггера).

It is also possible to specify the Exclusion mask for the Physical Trigger that is used to prevent detecting collisions with shapes. This mask is independent of the Collision mask.Также можно указать маску Exclusion для Physical Trigger, которая используется для предотвращения обнаружения столкновений с другими формами (shapes). Эта маска не зависит от маски Collision.

  • For a body with a shape, the Exclusion mask can be set on the Physics tab of the Parameters panel.Для тела с формой (shape) маска Exclusion может быть установлена на вкладке Physics панели Parameters.
  • For the Physical Trigger, the mask can be set via C++, C# or UnigineScript API.Для Physical Trigger маска может быть установлена через C ++, C # или UnigineScript API .

To avoid collision detection between a shape and a Physical Trigger, the following conditions must be met:Чтобы избежать обнаружения столкновений между фигурой и Physical Trigger, должны быть выполнены следующие условия:

  • The Collision mask set for the shape must match the Collision mask of the Physical Trigger.Маска Collision, установленная для фигуры, должна совпадать с маской Collision из Physical Trigger.
  • The Exclusion mask set for the shape must match the Exclusion mask of the Physical Trigger.Маска Exclusion, установленная для фигуры, должна совпадать с маской Exclusion из Physical Trigger.

Physical objects participating in the contact with the Physical Trigger can be obtained via API. The shape of such object scan also be obtained. Moreover, you can get the depth of the object penetration, coordinates of the contact point, and its normal.Физические объекты, участвующие в контакте с Physical Trigger, можно получить через API. Также можно получить конкретную форму (shape) такого объекта. Кроме того, вы можете получить глубину проникновения объекта, координаты точки контакта и нормали к ней.

See alsoСмотрите также#

Adding Physical TriggerДобавление физического триггера#

To add a Physical Trigger to the scene via UnigineEditor:Чтобы добавить Physical Trigger в сцену через UnigineEditor:

  1. Run the project with UnigineEditor.Запустите проект с UnigineEditor.
  2. On the Menu bar, click Create -> Logic -> Physical Trigger.В главном меню выберите Create -> Logic -> Physical Trigger.

  3. Click somewhere in the world to place the Physical Trigger.Щелкните где-нибудь в мире, чтобы разместить файл Physical Trigger.

A new Physical Trigger node will be added to UnigineEditor, and you will be able to edit it via the Parameters window. By default, the sphere trigger with 1-unit radius is created.Новый узел Physical Trigger будет добавлен в UnigineEditor, и вы сможете редактировать его через окно Parameters. По умолчанию создается сферический триггер с радиусом 1.

Editing Physical TriggerРедактирование физического триггера#

In the Physical Trigger section (Parameters window -> Node tab), you can adjust the following parameters of the physical trigger:В разделе Physical Trigger (окно Parameters → вкладка Node) вы можете настроить следующие параметры физического триггера:

Edit Size

Toggles the editing mode for the Physical Trigger node. When enabled, the size or the radius of the node (depending on its type) can be changed: each side/axis is highlighted with the colored rectangle/circle. To change the size/radius, drag the corresponding rectangle/circle.Переключает режим редактирования для узла Physical Trigger. При включении размер или радиус узла (в зависимости от его тип ) можно изменить: каждая сторона / ось выделяется цветным прямоугольником / кружком. Чтобы изменить размер / радиус, перетащите соответствующий прямоугольник / круг.

Editing of sphere-shaped physical triggerРедактирование сферического физического триггера
Physical Mask The Physical mask of the Physical Trigger must match the Physical mask of the physical object. Otherwise, the Physical Trigger won't trigger events when the object enters or leaves it.Маска Physical для Physical Trigger должна совпадать с маской Physical физического объекта. В противном случае Physical Trigger не будет запускать обратные вызовы, когда объект входит или выходит из него.
Collision Mask
  • In case of the physical object, the Collision mask of the Physical Trigger must match the Collision mask of the physical object's shape.В случае физического объекта маска Collision для Physical Trigger должна совпадать с маской Collision формы физического объекта.
  • In case of the non-physical collider object, the Collision mask of the Physical Trigger must match the Collision mask of the object's surface.В случае нефизического объекта коллайдера маска Collision для Physical Trigger должна совпадать с маской Collision поверхности объекта.
Type Type of the Physical Trigger: sphere, capsule, cylinder, or box.Тип файла Physical Trigger: sphere, capsule, cylinder или box.
Size

Size of the Physical Trigger, namely:Размер Physical Trigger, а именно:

  • Radius in case of a sphereРадиус в случае шара
  • Radius and height in case of a capsule or a cylinderРадиус и высота в случае капсулы или цилиндра
  • Dimensions in case of a boxРазмеры в случае параллелепипеда

Handling EventsОбработка событий#

To perform specific actions when physical objects enter or leave the Trigger, you should create a handler function that receives a Body as its first argument and implements the desired actions. Then subscribe to the Enter and/or Leave events and call connect().Чтобы выполнять определенные действия, когда физические объекты входят в триггер или выходят из него, следует создать функцию-обработчик, которая получает Body в качестве первого аргумента и реализует нужные действия. Затем нужно подписаться на события Enter и/или Leave и вызвать connect().

Исходный код (C++)
// subscribe to Enter event when a body enters the physical trigger with your handler
physicalTrigger->getEventEnter().connect(enter_event_handler);
// subscribe to Leave event when a body leaves the physical trigger with your handler
physicalTrigger->getEventLeave().connect(leave_event_handler);
Исходный код (C#)
// subscribe to Enter event when a body enters the physical trigger with your handler
physicalTrigger.EventEnter.Connect(enter_event_handler);
// subscribe to Leave event when a body leaves the physical trigger with your handler
physicalTrigger.EventLeave.Connect(leave_event_handler);
Последнее обновление: 19.04.2024
Build: ()