This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

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: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 fire callbacks 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包装盒尺寸

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.要添加回车或离开回调,请编写一个回调函数,该函数将Body作为其第一个参数。然后使用addEnterCallback()addLeaveCallback方法指定要调用的函数。

源代码 (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));
源代码 (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);
最新更新: 2023-06-23
Build: ()