Wiki

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 
}

Hands-On Notes

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.

Hands-On Usage

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
    }
}

Synergy

  • [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.

Common Pitfalls

  1. The id must point to an existing entity: 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.
  2. Angle units are radians, not degrees: Beginners often mistakenly use degree values (such as entering 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.