SpawnAction - acrimi/Raven GitHub Wiki

SpawnAction spawns a new entity relative to the position of the spawning entity. The spawned entity will inherit the orientation of the spawning entity at the time of execution.

Configuration

The following parameters can be used to configure the action's behavior:

Key Type Description
type string The type of entity to spawn
tag string An optional tag to add to entities that are spawned
child boolean Whether the spawned entity should be attached as a child of the spawning entity's TransformComponent or as a standalone entity. Defaults to false.
velocity float|object A velocity that will be applied to the spawned entity relative to the spawning entity's orientation. A simple forward velocity can be supplied as a direct velocity, or a 2-dimensional relative velocity can be supplied as an object.
      lateral float The lateral velocity of the spawned entity relative to the spawning entity's orientation. Positive values move to the spawning entity's right, negative values to the left.
      forward float The forward velocity of the spawned entity relative to the spawning entity's orientation. Positive values move towards the front of the spawning entity, negative values towards the back.
alignment string The case-insensitive name of the alignment that should be used to position the spawned entity relative to the parent entity. See EntityAlignment for all values. Defaults to "center".
offset object An object containing the offset that should be applied to the spawned entity relative to its initial alignment. Individual offsets can be configured for each entity orientation.
      x float The default x offset that will be used for any orientation that doesn't have a custom offset specified
      y float The default y offset that will be used for any orientation that doesn't have a custom offset specified
      lateral float The lateral offset of the spawned entity relative to the spawning entity's orientation. Positive values move to the spawning entity's right, negative values to the left. Ignored if either x or y are defined.
      forward float The forward offset of the spawned entity relative to the spawning entity's orientation. Positive values move towards the front of the spawning entity, negative values towards the back. Ignored if either x or y are defined.
      mirrored boolean Whether or not the left/right offsets should be mirrored around the entity's horizontal axis when the opposite direction is missing. This can help avoid creating redundant configurations for each direction. Defaults to true.
      [orientation] object An object containing the offsets that should be applied to the spawned entity for the orientation named by this key. The key should correspond to the lowercased name of an EntityOrientation (eg "right", "up", etc).
            x float The x offset that will be applied for this orientation
            y float The y offset that will be applied for this orientation
initializationData object An optional configuration object that will be applied to the spawned entity. Supports all properties allowed in entity templates. Will be merged with any existing templates configured for the entity's type.

Examples:

"eventName": {
  "action": "SpawnAction",
  "type": "bomb",
  "tag": "playerDrop",
  "child": true,
  "velocity": 10,
  "offset": {
    "lateral": 2,
    "forward": -1
  }
}
"eventName": {
  "action": "SpawnAction",
  "type": "bomb",
  "tag": "playerDrop",
  "velocity": {
    "lateral": 0,
    "forward": 10
  },
  "alignment": "origin",
  "offset": {
    "x": -1,
    "y": 6,
    "up": {
      "x": -1,
      "y": -6
    },
    "right": {
      "x": -6,
      "y": -1
    }
  }
}