Difference between revisions of "SpawnEntityFromArchetype"

From Nomad DB
m
m
Line 29: Line 29:
 
* [[Archetype]]
 
* [[Archetype]]
  
[[Category:WD2 Lua]] [[Category: WD2 Entity]] [[Category: WD2 Player]]
+
[[Category:WD2 Lua]] [[Category: WD2 Entity]]

Revision as of 12:25, 16 April 2020

Spawns an entity of the specified archetype at the specified position.

Syntax

SpawnEntityFromArchetype(archetype, xPos, yPos, zPos, xRot, yRot, zRot)
  • archetype (string): Archetype of the target entity
  • xPos (number): X component of the target spawn position coordinates
  • yPos (number): Y component of the target spawn position coordinates
  • zPos (number): Z component of the target spawn position coordinates
  • xRot (number): X component of the target spawn orientation in Degrees
  • yRot (number): Y component of the target spawn orientation in Degrees
  • zRot (number): Z component of the target spawn orientation in Degrees
  • Returns (string): ID of the spawned entity.

Example

The example below spawns a bike and prints the name of the entity.

local archetype = "{5a8ef904-070b-4706-8c23-788f6b82a30e}"
local destinationEntity = GetLocalPlayerEntityId()
local spawnedEntity = SpawnEntityFromArchetype(archetype, GetEntityPosition(destinationEntity, 0), GetEntityPosition(destinationEntity, 1), GetEntityPosition(destinationEntity, 2), GetEntityAngle(destinationEntity, 0), GetEntityAngle(destinationEntity, 1), GetEntityAngle(destinationEntity, 2))
local spawnedEntityName = GetEntityName(spawnedEntity)
print(spawnedEntityName) -- returns "Vehicle_Bike.Bike.Bike_01"

Related Pages