This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
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
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
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.

Physical Trigger

The Physical Trigger is an object firing callbacks when physical objects get inside or outside of it. There are 4 types of physical triggers based on their shape:

  • 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).

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.

To avoid collision detection between a shape and a Physical Trigger, the following conditions must be met:

  • The Collision mask set for the shape must match the Collision mask of the Physical Trigger.
  • The Exclusion mask set for the shape must match the Exclusion mask of the 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.

See also#

Adding Physical Trigger#

To add a Physical Trigger to the scene via UnigineEditor:

  1. Run the project with UnigineEditor.
  2. On the Menu bar, click Create -> Logic -> Physical Trigger.

  3. Click somewhere in the world to place the 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.

Editing Physical Trigger#

In the Physical Trigger section (Parameters window -> Node tab), you can adjust the following parameters of the physical trigger:

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.

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 fire callbacks when the object enters or leaves it.
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.
  • 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.
Type Type of the Physical Trigger: sphere, capsule, cylinder, or box.
Size

Size of the Physical Trigger, namely:

  • Radius in case of a sphere
  • Radius and height in case of a capsule or a cylinder
  • Dimensions in case of a box

Setting Up Callbacks#

To add an enter or leave callback, write a callback function that receives a Body as its first argument. Then use an addEnterCallback() or addLeaveCallback method to specify the function to be called.

Source code (C++)
// add the enter callback to be fired when a body enters the physical trigger
physicalTrigger->addEnterCallback(MakeCallback(this, &AppWorldLogic::enter_callback));
// add the leave callback to be fired when a body leaves the physical trigger
physicalTrigger->addLeaveCallback(MakeCallback(this, &AppWorldLogic::leave_callback));
Source code (C#)
// add the enter callback to be fired when a body enters the physical trigger
physicalTrigger.addEnterCallback(enter_callback);
// add the leave callback to be fired when a body leaves the physical trigger
physicalTrigger.addLeaveCallback(leave_callback);
Last update: 2022-12-14
Build: ()