World Trigger
A world trigger is a cuboid shaped object, which triggers events when any node (physical or not) gets inside or outside of it. The trigger can detect a node of any type by its bound object and can be used to access node's components and parameters.world trigger是一个长方体形状的对象,当任何节点(无论是否存在)进入其内部或外部时,都会触发回调。触发器可以通过其触发器检测任何类型的节点绑定对象并且可以用来访问节点的组件和参数。
- Dummy Node
- Node Reference
- Node Layer
- World Switcher
- World Transform Path
- World Transform Bone
- World Expression
- Dummy Object (if it has no body assigned)Dummy Object (if it has no body assigned)
- Dummy Node
- Node Reference
- Node Layer
- World Switcher
- World Transform Path
- World Transform Bone
- World Expression
- Dummy Object (if it has no body assigned)Dummy Object(如果没有) 身体分配)
See also也可以看看#
- WorldTrigger class to manage World Trigger via APIWorldTrigger类可通过API管理World Trigger
-
A set of samples located in the data/samples/worlds folder:位于data/samples/worlds文件夹中的一组样本:
- trigger_01
- trigger_02
- Videotutorial on How To Use World Triggers to Detect Nodes by Their Bounds视频教程: 如何使用触发器按边界检测节点
Creating a World Trigger创建一个世界触发器#
To create World Trigger via UnigineEditor:要通过UnigineEditor创建World Trigger,请执行以下操作:
-
On the Menu bar, choose Create -> Logic -> World Trigger在菜单栏上,选择Create -> Logic -> World Trigger
- Place the node in the scene.将节点放置在场景中。
Editing a World Trigger编辑世界触发器#
In the Node tab of the Parameters window, you can adjust the following parameters of World Trigger:在Parameters窗口的Node选项卡中,可以调整World Trigger的以下参数:
Bounding Box Parameters边界框参数#
A set of bounding box parameters:一组边界框参数:
Edit Size |
Toggles the editing mode for the World Trigger node on and off. When enabled, the bounding box sides that can be resized are highlighted with the colored rectangles. To change the size of a side, drag the corresponding rectangle.开启和关闭World Trigger节点的编辑模式。启用后,可以调整大小的边界框边将用彩色矩形突出显示。要更改边的大小,请拖动相应的矩形。 |
---|---|
Touch | Toggles the touch mode for World Trigger on and off. With this mode on, World Trigger reacts to the node at a partial contact. Otherwise, World Trigger reacts only if the whole bounding box gets inside it.开启和关闭World Trigger的触摸模式。启用此模式后,World Trigger在部分接触时对节点做出反应。否则,仅当整个边界框进入内部时,World Trigger才会做出反应。 |
Size | The size of the World Trigger bounding box along the X, Y, and Z axes, in units.沿X, Y和Z轴的World Trigger边界框的大小,以单位为单位。 |
Handling Events设置回调#
To perform specific actions when a node enters or leaves the World Trigger, you should implement event handlers that receive a Node as the first argument. Then, you should subscribe to the Enter and/or Leave events and call connect().要在节点进入或离开World Trigger时执行特定的操作,您应该实现接收 node 作为第一个参数的事件处理程序。然后,您应该订阅输入和/或离开事件并调用connect()。
// subscribe to the Enter event when a node enters the world trigger with your handler
worldTrigger->getEventEnter().connect(enter_event_handler);
// subscribe to the Leave event when a node leaves the world trigger with your handler
worldTrigger->getEventLeave().connect(leave_event_handler);
// subscribe to the Enter event when a node enters the world trigger with your handler
worldTrigger.EventEnter.Connect(enter_event_handler);
// subscribe to the Leave event when a node leaves the world trigger with your handler
worldTrigger.EventLeave.Connect(leave_event_handler);