This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

World Expression

A world expression is a point object, which executes arbitrary expressions (scripts) at the specified distance and frame rate. By default, expressions are executed at the same frame rate as the main application.

Notice
An expression is executed only if it's within the specified range of the distance from the camera.

By using world expressions, you can attach a script to an object in the scene. To do that, such object must be added as a child node to the world expression. Child nodes inherit transformations (if any) of the world expression.

Notice
Child nodes are transformed relative to the pivot point of the world expression node.
If there are nested world expression nodes, the child node of the last world expression in the hierarchy inherits transformations of all parent world expression nodes.

For example, by using the world expression, you can transform objects in the scene, turn on and off sounds with the distance, turn on and off NPC behavior, attach objects to the camera (e.g. drops of the rain on the camera), and so on.

ObjectMeshDynamic nodes added as children to the nested WorldExpression nodes

See also#

Creating World Expression#

To create a world expression via UnigineEditor:

  1. In the Menu bar, click Create -> Logic -> Expression.

  2. Place the world expression somewhere in the world.

Attaching World Expression Script#

There are two ways of attaching a world expression script via UnigineEditor:

  • Directly in UnigineEditor in the Parameters window -> Node tab -> World Expression section -> Source field. The source code must be inside the curly braces {} as they define the world expression scope.

  • Attached as a script file in the Parameters window -> Node tab -> World Expression section -> File field. The script file should be included in the world expression scope in the Source field. The curly braces {} are also required:

    In this case, the my_expression.h should contain the following code:
    Source code (UnigineScript)
    log.message("WorldExpression is updated\n");
    Notice
    In the script file, the source code must not be wrapped with curly braces {}.

Implementing Script#

The script itself can be implemented as a simple sequence of functions' calls or as a set of functions and classes. See examples here.

Notice
It is recommended to implement simple scripts.

Inter-Script Communication#

Such script can communicate with the world script via the corresponding engine.world functions or with world triggers via callbacks (see the samples listed above).

Script Functions#

Besides functions of the UnigineScript library, there is also a set of internal functions that are available within the world expression script. The list of such functions with descriptions and examples can be found here.

Setting World Expression Parameters#

You can adjust the following parameters of the world expression in the Node tab:

Update Distance Limit Range of the distance from the camera, within which the expression is executed.
IFps A constant frame duration (inverse FPS, 1/FPS) used to execute the expression. If 0 is set, the expression is executed at the same frame rate as the main application.
File A path to a file with a world expression script to be executed. The path is relative to the data directory. This file should be included in the world expression scope in the Source field. This field is optional as the world expression script can be implemented directly via the UnigineEditor interface (see the description of the Source field below).
Notice
If the script file is changed, it should be refreshed via UnigineEditor: click to the right of the File field.
Source Source code of a world expression script. This field can contain:
  • Direct implementation of the world expression script.
  • The #include directive that loads the script file specified in the File field (see the description above).
Notice
In both cases, the curly braces {} must wrap the code in the field.

Deleting World Expression#

To delete the world expression via UnigineEditor, right-click the world expression node in the nodes hierarchy list and press Delete.

Last update: 2021-04-09
Build: ()