Creating a unit between two existing ones

Flow

New Member
Reaction score
4
Right, so I want a spell which creates a unit between the caster and the target, who will in turn cast the actual spell and then disappear. However, I can't get the actual unit creation to work. I'm very unsure about how to get it in between two units, and right now it looks like this:



Unit - Create 1 UNIT_X for Neutral Passive at (Center of (Region((Position of (Casting unit)), (Position of (Targeted unit))))) facing (Position of (Target unit of ability being cast))


In other words, I used the "Conversion - Convert points to region" option.

Nothing appears between the two units, so I thought I'd consult the pros ;)
 

Drunken_God

Hopes to get back into Mapmaking with SC2 :)
Reaction score
106
you would have to get the distance between both units and half it
(does your unit needs to be created in the middle?)
 

Flow

New Member
Reaction score
4
It doesn't have to be created *exactly* in the middle, anywhere between the two of them is fine.
 

Drunken_God

Hopes to get back into Mapmaking with SC2 :)
Reaction score
106
then do sth like(freehand):

set distance = (distance between (triggering unit) and (target unit)
set middle = {point with polar offset} (pos of triggerin unit offset by (distance/2) towards (angle between pos of triggering unit and pos of target))

create unit at middle...
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Set P1 = Position of (<some unit>)
Set P2 = Position of (<some other unit>)
Set X = (X of (P1) + X of (P2)) / 2.0
Set Y = (Y of (P1) + Y of (P2)) / 2.0
Set Point = Location from coordinates x and y
Unit - Create 1 <whatever> for <someone> at Point facing Default
Custom script: call RemoveLocation( udg_Point )
Custom script: call RemoveLocation( udg_P1 )
Custom script: call RemoveLocation( udg_P2 )


Then again, this is really one of those times where JASS is just simpler:
JASS:
function BetweenUnits takes unit u1,unit u2 returns location
return Location((GetUnitX(u1) + GetUnitX(u2)) / 2.0, (GetUnitY(u1) + GetUnitY(u2)) / 2.0)
endfunction


Can be used from GUI too:
Set Unit1 = <this unit>
Set Unit2 = <that unit>
Custom script: set udg_Point = BetweenUnits( udg_Unit1, udg_Unit2 )
Unit - Create 1 <whatever> for <someone> at Point facing Default
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top