World Trigger
A world trigger is a cuboid shaped object, which fires callbacks 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边界框的大小,以单位为单位。 |
Setting Up Callbacks设置回调#
To add an enter or leave callback, write a callback function that receives a Node as its first argument. Then use the addEnterCallback or addLeaveCallback method to specify the function to be called.要添加回车或离开回调,请编写一个接收以下内容的回调函数:节点作为第一个论点。然后使用addEnterCallback或addLeaveCallback方法指定要调用的函数。
// add the enter callback to be fired when a node enters World Trigger
worldTrigger->addEnterCallback(MakeCallback(this, &AppWorldLogic::enter_callback));
// add the leave callback to be fired when a node leaves World Trigger
worldTrigger->addLeaveCallback(MakeCallback(this, &AppWorldLogic::leave_callback));
// add the enter callback to be fired when a node enters World Trigger
worldTrigger.AddEnterCallback(enter_callback);
// add the leave callback to be fired when a node leaves World Trigger
worldTrigger.AddLeaveCallback(leave_callback);