触发器

此功能自 BeamNG.tech 和 .drive 版本 0.14.0 开始支持。

触发器(Triggers)部分用于在车辆上定位可点击的区域,这些区域模拟按钮、开关、车门把手以及其他手动操作的部件。

该部分不能单独存在。它需要配合 Event(事件)部分(用于决定要执行的代码)以及 TriggerEventLinks(用于将两者关联起来)。

  • events 定义了实际要执行的操作(类似于 input_actions.json,但在零部件内部)
  • triggerEventLinkstriggers(触发器)和 events (事件)关联起来

0.38.5.0 contains 3 entries in 1 sections distributed over 20043 parts in 5090 jbeam files.

触发器部分参数说明

string
type
唯一标识触发器。整个车辆内必须唯一
string
type
如果不为空,将在触发器上方显示描述性文字
number
type
坐标系的参考节点
number
type
坐标系的 X 节点
number
type
坐标系的 Y 节点
string
type
触发器的类型

可用值:

  • box(盒状)
  • sphere(球状)
dictionary 或 number
type
{“x”:1, “y”:1, “z”:1} (box), 1 (sphere)
default
Box 类型时为 3D 尺寸,Sphere 类型时为半径

Box 类型示例值:

{"x":0.25, "y":0.05, "z":0.08}

Sphere 类型示例值:

0.25
dictionary
type
{“x”:0, “y”:0, “z”:0}
default
欧拉角旋转(度)

使用内部欧拉 -X -Z -Y 旋转系统,旋转中心为定义位置的盒子的一个角。

示例值:

{"x":0, "y":0, "z":0}
dictionary
type
{“x”:0, “y”:0, “z”:0}
default
欧拉角旋转(度)
用于动画等。目前暂未使用。
dictionary
type
{“x”:0, “y”:0, “z”:0}
default
本地坐标系下的平移
用于动画等。目前暂未使用。
dictionary
type
{“x”:0, “y”:0, “z”:0}
default
本地坐标系下的初始平移

使用内部欧拉 -X -Z -Y 旋转系统,旋转中心为定义位置的盒子的一个角。

示例值:

{"x":0.2, "y":0.26, "z":-0.05}

TriggerEventLinks 部分参数说明

string
type
触发器的 ID
string
type
用于触发事件的输入动作名称

常用值有:

  • action0 = 鼠标左键
  • action1 = 鼠标右键
  • action2 = 鼠标中键
string
type
事件的 ID

Events 部分参数说明

必要参数

string
type
唯一标识该事件。在整个车辆范围内必须唯一
string
type
操作 的标题
操作的简短名称,将显示在各种游戏菜单中
string
type
操作 的描述
完整描述,可能会作为工具提示显示,应该是一句话说明

可选参数

事件要生效,至少要定义其中一个。

string
type
当触发器输入变化时要执行的代码
string
type
当触发器输入被按下时要执行的代码
string
type
当触发器输入被松开时要执行的代码

简易示例

{
  "triggers":[
    ["id", "label", "idRef:", "idX:", "idY:","type", "size", "baseRotation", "rotation","translation", "baseTranslation"],
    ["cargodoorR", "", "cd4r","cd4rr","cd3r", "box",{"x":0.25, "y":0.05, "z":0.08},{"x":0, "y":0, "z":0},{"x":0, "y":0, "z":0},{"x":0, "y":0, "z":0},{"x":0.2, "y":0.26, "z":-0.05}],
  ],
  "triggerEventLinks":[
    ["triggerId:triggers", "action", "targetEventId:events"],
    ["cargodoorR", "action0", "toggle_doorR"]
  ],
  "events":[
    ["id", "title", "desc"],
    ["toggle_doorR", "ui.inputActions.van.toggle_doorR.title", "ui.inputActions.van.toggle_doorR.description", {"onUp":"electrics.values.doorR = 1-(electrics.values.doorR or 0)", "order": 2}]
  ],
}
上一次修订: 五月 20, 2026

还有其他问题?

加入我们的 Discord 服务器
Our documentation is currently incomplete and undergoing active development. If you have any questions or feedback, please visit this forum thread.