CreateUnit
- Parameters
-
id player
The owner of the unit.
unitid integer
The rawcode of the unit.
x real
The x-coordinate of the unit.
y real
The y-coordinate of the unit.
face real
Unit facing in degrees.
- 0 = East
- 90 = North
- 180 = West
- 270 = South
- -90 = South (wraps around)
- comment
Creates a unit of type
unitid
for playerid
, facing a certain direction at the provided coordinates. Returns handle to unit.Example: Create a human footman for first player (red) at map coordinates -30, 0, facing north:
// Jass call CreateUnit(Player(0), 'hfoo', -30, 0, 90)
-- Lua CreateUnit(Player(0), FourCC("hfoo"), -30, 0, 90)
- note
See:
bj_UNIT_FACING
constant for default facing direction of units in BJ scripts and GUI.- note
If you want to create a unit with a specific shadow you can use something along these lines. See also.
// Dummy but valid image path required. local image i = CreateImage( "ReplaceableTextures\\Splats\\AuraRune9b.blp", 1, 1, 0, 0, 0, 0, 1, 1, 0, 3) local unit u // If the image creation failed, abort, as it can screw up the game. if GetHandleId(i) == -1 then return endif call DestroyImage(i) set u = CreateUnit(Player(0), 'hpea', 0, 0, 0) // Destroy the units shadow, because it seems like you can't really work with it. call DestroyImage(i) // Create a new image. This will be the units new shadow. call CreateImage( "ReplaceableTextures\\Splats\\AuraRune9b.blp", 128, 128, 0, 0, 0, 0, 0, 0, 0, 1) // Now you can do stuff with the image that is u's shadow. // Do note though that you cannot change the position of the image. call SetImageRenderAlways(i, true) call SetImageColor(i, 255, 0, 0, 255)
- patch
1.00
- Source
- common.j
- return type
unit
- Source code
native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit