effect · set_entity_rotation
Definition
- Supported scope:
any - Supported target:
any
Description
sets the rotation of existing entity
set_entity_rotation = {
id = 123 # id of entity
rotation = 0.23 # angle in radians
}
set_entity_rotationanyanysets the rotation of existing entity
set_entity_rotation = {
id = 123 # id of entity
rotation = 0.23 # angle in radians
}
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
set_entity_rotation 常用于动态视觉演出场景,例如让地图上的自定义实体(路障、炮台、装饰物等)在特定事件触发后转向特定角度,或模拟炮管旋转、指针偏转等动画效果。配合事件或决议触发,可以在不重新创建实体的情况下改变已有实体的朝向。
# 在某个事件 option 中,将已创建的实体旋转 90 度(约 1.5708 弧度)
effect = {
set_entity_rotation = {
id = 42
rotation = 1.5708
}
}
[create_entity](/wiki/effect/create_entity):先用 create_entity 创建实体并记录其 id,之后才能用 set_entity_rotation 通过同一 id 对其进行旋转操作,两者是典型的"创建-变换"搭档。[set_entity_position](/wiki/effect/set_entity_position):在调整实体位置的同时往往也需要调整朝向,两个命令通常在同一执行块中先后出现,共同完成实体的空间变换。[set_entity_animation](/wiki/effect/set_entity_animation):旋转只改变静态角度,若需要在旋转的同时播放动画(如炮塔转动后开火),需要配合此命令触发对应的动画状态。[destroy_entity](/wiki/effect/destroy_entity):演出结束后通常需要清除实体,销毁前可先用 set_entity_rotation 做最终姿态还原,保证下次创建时状态一致。set_entity_rotation 只能操作已通过 create_entity 创建且尚未被 destroy_entity 销毁的实体。若 id 对应的实体不存在,命令会静默失败,不会报错,导致旋转效果毫无反应,调试时容易忽略。90 表示 90°),但游戏实际需要弧度值(90° 应填约 1.5708)。填错单位会造成实体旋转到完全意料之外的方向。Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.
set_entity_rotation is commonly used in dynamic visual sequences, such as rotating custom entities on the map (barricades, gun emplacements, decorative objects, etc.) to specific angles after certain events trigger, or simulating animations like cannon barrel rotation or pointer deflection. Combined with event or decision triggers, you can change the orientation of existing entities without recreating them.
# In an event option, rotate an already-created entity by 90 degrees (approximately 1.5708 radians)
effect = {
set_entity_rotation = {
id = 42
rotation = 1.5708
}
}
[create_entity](/wiki/effect/create_entity): First use create_entity to spawn an entity and record its id, only then can you use set_entity_rotation to rotate it via the same id. These two are the archetypal "create-transform" pair.[set_entity_position](/wiki/effect/set_entity_position): When adjusting entity position, you typically need to adjust orientation as well. Both commands commonly appear sequentially in the same execution block to complete the entity's spatial transformation together.[set_entity_animation](/wiki/effect/set_entity_animation): Rotation only changes the static angle. If you need to play an animation while rotating (such as firing after a turret rotates), you must use this command to trigger the corresponding animation state.[destroy_entity](/wiki/effect/destroy_entity): After the sequence ends, you typically need to clean up the entity. Before destruction, you can use set_entity_rotation to restore the final pose, ensuring consistency when recreating it next time.set_entity_rotation can only operate on entities that were created via create_entity and have not yet been destroyed by destroy_entity. If the id corresponds to a non-existent entity, the command fails silently without error, resulting in no rotation effect whatsoever—an easy mistake to overlook during debugging.90 for 90°), but the game actually requires radians (90° should be approximately 1.5708). Using the wrong unit causes the entity to rotate to a completely unexpected direction.