• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Creating Unit in front of a unit

Status
Not open for further replies.
Level 2
Joined
Jan 18, 2018
Messages
11
so i want a trigger that will create a unit 2 in front of another unit 1
i made a trigger that will create a unit 2 but it seems to be creating the unit 2 at the bottom of the unit 1
but i want it to get created in front of it (if the unit 1 facing to the right the unit 2 should be created at the right side of the unit 1)
 
Last edited:
Level 13
Joined
May 10, 2009
Messages
868
You just need to use the "Point with Polar Offset" function. Two point variables are also needed: A for defining where the first unit should be created, and B for storing the "Point with polar offset" value and create the second unit with it. In that function, you need to specify what's the distance between both units, and which angle the second unit should follow.

  • Set pointA = (Center of Somewhere <gen>)
  • Unit - Create 1 Footman for Player 1 (Red) at pointA facing (Random angle) degrees
  • Set pointB = (pointA offset by 125.00 towards (Facing of (Last created unit)) degrees)
  • Unit - Create 1 Footman for Player 1 (Red) at pointB facing (Facing of (Last created unit)) degrees
  • Custom script: call RemoveLocation(udg_pointA)
  • Custom script: call RemoveLocation(udg_pointB)
 
Level 10
Joined
Apr 4, 2010
Messages
286
BloodSoul's trigger is great. Here's a slightly tweaked version for if Unit 1 already exists.

  • Set pointA = (Position of (Unit 1))
  • Set pointB = (pointA offset by 125.00 towards (Facing of (Unit 1)) degrees)
  • Unit - Create 1 Footman for Player 1 (Red) at pointB facing (Facing of (Unit 1)) degrees
  • Custom script: call RemoveLocation(udg_pointA)
  • Custom script: call RemoveLocation(udg_pointB)
 
Status
Not open for further replies.
Top