This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
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

视频教程: 如何使用触发器按边界检测节点

注意
每个视频都有英文,俄文和中文字幕。
警告
本教程使用SDK版本2.18创建。这些建议不适用于早期版本。


当任何节点(碰撞体或任何其他类型)进入内部或离开World Trigger时,WorldTrigger都会触发回调

触发器可以通过其边界框检测任何类型的节点。

为了方便您使用,本视频中展示的组件代码如下:

DeleteObject.cs
using System.Collections;
using System.Collections.Generic;
using Unigine;

[Component(PropertyGuid = "AUTOGENERATED_GUID")] // <-- this line is generated automatically for a new component
public class DeleteObject : Component
{
	WorldTrigger worldTrigger;
	void enter_event_handler(Node target)
	{
		// Delete the object on entering the trigger
		target.DeleteLater();
	}
	void Init()
	{
		// Cast Node to WorldTrigger
		worldTrigger = node as WorldTrigger;

		if(worldTrigger){
			// Subscribe for Enter event to perform actions 
			// when a node enters the trigger
			worldTrigger.EventEnter.Connect(enter_event_handler);
		}
		
	}
	
	void Update()
	{
		// Render node's visualizer
		node.RenderVisualizer();
		
	}
}
Mover.cs
using System.Collections;
using System.Collections.Generic;
using Unigine;

[Component(PropertyGuid = "AUTOGENERATED_GUID")] // <-- this line is generated automatically for a new component
public class Mover : Component
{
	void Init()
	{
		// write here code to be called on component initialization
		
	}
	
	void Update()
	{
		// move the node down
		node.Translate(new vec3(0.0f, 0.0f, Game.IFps * -1.0f));
		
		// render the bounding box
		Visualizer.RenderBoundBox(node.BoundBox, mat4.IDENTITY, new vec4(1.0f, 0.0f, 0.0f, 1.0f));
	}
}

要启用可视化工具,请在AppWorldLogic.cpp或任何合适的组件中的Init()方法中添加以下代码:

源代码 (C#)
// Enable Visualizer
Unigine.Console.Run("show_visualizer 1");

本页面上的信息适用于 UNIGINE 2.19.1 SDK.

最新更新: 2025-03-04
Build: ()