This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and 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
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
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.

Physical Trigger

A physical trigger is an object firing callbacks when physical objects or non-physical collider objects get inside or outside of it. There are 4 types of the physical triggers:

  • 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:

  • The 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).
  • The non-physical collider object must have 3 flags set:
    • The collider node flag.
    • The object surface collision flag (can be set via UnigineScript or on the Surface tab of the Nodes panel).
    • The collision flag in the surface_base property (both the property and this flag are assigned by default).

Also it is 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. For a body with a shape, the exclusion mask can be set on the Shapes tab of the Nodes panel. For the physical trigger, the mask can be set via UnigineScript. To avoid detecting collisions with a shape by the 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.

The physical objects participating in the contact with the physical trigger can be obtained via UnigineScript. The shape of such object can also be obtained. In addition, you can get the depth of the object penetration, coordinates of the contact point and its normal.

The surface of the non-physical collider objects can also be obtained via UnigineScript.

See also

  • A PhysicalTrigger class to edit physical trigger nodes via UnigineScript
  • A set of samples located in the data/samples/physicals folder:
    1. trigger_00
    2. trigger_01
    3. trigger_02

Adding Physical Trigger

To add a physical trigger to the scene via UnigineEditor:

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

  3. Click somewhere in the world to place the physical trigger.

The new physical trigger node will be added to UnigineEditor and you will be able to edit it via the Nodes panel. By default, the sphere trigger with 1 -unit radius is created.

Editing Physical Trigger

On the Trigger tab of the Nodes panel, you can adjust the following parameters of the physical trigger:

Physical 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 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.
Enter Name of the world script callback function to be fired on entering the physical trigger.
Leave Name of the world script callback function to be fired on leaving the physical trigger.
Last update: 2017-07-03
Build: ()