This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
Tutorials

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是当物理对象进入内部或外部时触发回调的对象。根据其形状,有四种类型的物理触发器:

  • 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.也可以为Physical Trigger指定Exclusion掩码,用于防止检测形状冲突。此掩码独立于Collision掩码。

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遮罩必须比赛Physical TriggerCollision掩码。
  • The Exclusion mask set for the shape must match the Exclusion mask of the Physical Trigger.为形状设置的Exclusion遮罩必须比赛Physical TriggerExclusion掩码。

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.可以通过API获取参与Physical Trigger接触的物理对象。还可以获得这种对象扫描的形状。此外,您可以获得对象穿透的深度,接触点的坐标及其法线。

See also
也可以看看#

Adding Physical Trigger
添加物理触发器#

To add a Physical Trigger to the scene via UnigineEditor:通过UnigineEditor将Physical Trigger添加到场景中:

  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 TriggerPhysical掩码必须比赛物理对象的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.对于物理对象,必须将Physical TriggerCollision掩码比赛物理对象形状的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.如果是非物理碰撞对象,则Physical TriggerCollision掩码必须比赛对象表面的Collision蒙版。
Type Type of the Physical Trigger: sphere, capsule, cylinder, or box.Physical Trigger的类型:sphere, capsule, cylinderbox
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);
最新更新: 2024-12-13
Build: ()