• 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.

[Solved] Can I create a point to the left of a unit?

Status
Not open for further replies.
Level 11
Joined
Apr 17, 2011
Messages
302
So I'm trying make it so a unit will move to the left side of a unit depending on their current location.

So for example my hero goes and talks to an NPC I want companion unit to move to the left of that unit.

I've tried messing around with a the position of the unit with offset, but that works on the X and Y grid of the Warcraft map, not dependant on which way the hero is facing.

Help please.
 
Level 23
Joined
Feb 6, 2014
Messages
2,466
JASS:
local real x = GetUnitX(NPC)
local real y = GetUnitY(NPC)
local real facing = (GetUnitFacing(NPC) + 90)*bj_DEGTORAD
local real offset = 15 //how much farther the left side from the unit
local real x2 = x + offset*Cos(facing)
local real y2 = y + offset*Sin(facing)

If you know JASS, you can use that.
x2 and y2 are the left position of the NPC 15 distance away.
 
Level 14
Joined
Nov 17, 2010
Messages
1,266
You can move the unit to a point offset by however far you want and make the angle equal the facing angle of the main unit + 90 degrees can't you?
 
Level 11
Joined
Apr 17, 2011
Messages
302
JASS:
local real x = GetUnitX(NPC)
local real y = GetUnitY(NPC)
local real facing = (GetUnitFacing(NPC) + 90)*bj_DEGTORAD
local real offset = 15 //how much farther the left side from the unit
local real x2 = x + offset*Cos(facing)
local real y2 = y + offset*Sin(facing)

If you know JASS, you can use that.
x2 and y2 are the left position of the NPC 15 distance away.

I'm working using gui, not to sure how to use Jass at all.
So thank you but I am very unsure how to use it.

You can move the unit to a point offset by however far you want and make the angle equal the facing angle of the main unit + 90 degrees can't you?

This is my problem, I don't think I can change the angle of the point. The point set is a point on the warcraft 3 map grid, offset by a grid around the area of the point.

So I'm not to sure how I can do it, I suppose I could check what direction the unit is facing and change the offset depending, but I'm sure there is a way to implement an angle instead of all that.
 
Level 3
Joined
Jun 17, 2015
Messages
53
i remember i requested a spell that creates 3 lizzards behind caster include left and right but dont remember, like ppl said it maybe +90 so

My trigger of that spell
  • Set SD_Loc[0] = (Position of SD_Caster)
  • Set SD_Loc[1] = (Target point of ability being cast)
  • Set SD_Angle[1] = (Angle from SD_Loc[0] to SD_Loc[1])
  • -------- Behind --------
  • Set SD_Loc[2] = (SD_Loc[0] offset by 400.00 towards (SD_Angle[1] - 180.00) degrees)
  • -------- Right --------
  • Set SD_Loc[3] = (SD_Loc[2] offset by 200.00 towards (SD_Angle[1] + 90.00) degrees)
  • -------- Left --------
  • Set SD_Loc[4] = (SD_Loc[2] offset by 200.00 towards (SD_Angle[1] - 90.00) degrees)
 
Level 11
Joined
Apr 17, 2011
Messages
302
LeftSide = Position of NPC offset by someDistance towards (Facing Angle of NPC + 90)

Thank you, I tried messing with the point with polar offset but couldn't get it to work, this is the solution :)

i remember i requested a spell that creates 3 lizzards behind caster include left and right but dont remember, like ppl said it maybe +90 so

My trigger of that spell
  • Set SD_Loc[0] = (Position of SD_Caster)
  • Set SD_Loc[1] = (Target point of ability being cast)
  • Set SD_Angle[1] = (Angle from SD_Loc[0] to SD_Loc[1])
  • -------- Behind --------
  • Set SD_Loc[2] = (SD_Loc[0] offset by 400.00 towards (SD_Angle[1] - 180.00) degrees)
  • -------- Right --------
  • Set SD_Loc[3] = (SD_Loc[2] offset by 200.00 towards (SD_Angle[1] + 90.00) degrees)
  • -------- Left --------
  • Set SD_Loc[4] = (SD_Loc[2] offset by 200.00 towards (SD_Angle[1] - 90.00) degrees)

Yes, this is basically what Flux said at the top and it is just what I needed, thank you.
 
Status
Not open for further replies.
Top