Wiki

effect · set_entity_movement

Definition

  • Supported scope:any
  • Supported target:any

Description

sets the position & rotation of an existing entity using two coordinates
set_entity_movement = {
  id = 123 # id of entity 
  start = { 
    # position can be set using following 
    x = 42 
    y = 21 
    province = 123 
    state = 42 
    z = 3 #if wanted you can specify a z to shift height of the entity
  } 
  target = { 
    # position can be set using following 
    x = 42 
    y = 21 
    province = 123 
    state = 42 
    z = 3 #if wanted you can specify a z to shift height of the entity
  } 
  ratio = 0.5 # a ratio in between 0 - 1. the entity is positioned in between start & target position using this ratio 
  rotation = 1.2 # angle in radio, entity is rotated using the direction and this angle is added after that 
}

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_movement is commonly used in cinematic animation mods to make custom entities on the map (aircraft, ships, vehicle models, etc.) interpolate along a specified path. Combined with event chains that advance frame-by-frame, this creates cutscene effects. For example, in a story event showcasing fleet movement, you can simulate an entity gliding from a departure port to a target sea zone by continuously adjusting the ratio value:

# In the immediate block of an event, move the entity to the midpoint between start and target
set_entity_movement = {
    id = 101
    start = {
        province = 11620  # Province of departure port
    }
    target = {
        province = 11634  # Province of target sea zone
    }
    ratio = 0.5           # Currently positioned halfway along the route
    rotation = 1.57       # Rotation adjusted roughly eastward (in radians)
}

Synergy

  • [create_entity](/wiki/effect/create_entity) — Entities must be created before they can be moved by this command; both typically appear in different stages of the same event chain.
  • [set_entity_rotation](/wiki/effect/set_entity_rotation) — If you only need to adjust rotation without interpolating position, you can use this separately; it can also be called after movement for final rotation correction.
  • [set_entity_animation](/wiki/effect/set_entity_animation) — Movement often requires syncing the entity's animation state in parallel. Calling this command alongside movement ensures visual consistency.
  • [destroy_entity](/wiki/effect/destroy_entity) — Clean up entities no longer needed after the animation finishes, forming a complete lifecycle of "create → move → destroy" with this command.

Common Pitfalls

  1. ratio values outside the 0–1 range don't error but produce undefined behavior: Beginners sometimes pass ratio dynamically via variables. If a variable exceeds 1.0 through accumulation, the entity will interpolate beyond the target position, causing the model to appear off-map at an edge. Always constrain variables to the legal range using [clamp_variable](/wiki/effect/clamp_variable) or [clamp_temp_variable](/wiki/effect/clamp_temp_variable) before assignment.
  2. The id must correspond exactly with the id from create_entity: If you reference an entity id that hasn't been created yet or has already been destroyed by destroy_entity, the game won't crash but the command silently fails, making it extremely difficult to debug. It's recommended to clearly annotate the lifecycle of each id in comments within the same file.