• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Simple Question

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
  • Set r = (Angle from TempLoc to TempLoc2)
How to change that to JASS by using pure coordinates ?
Basically I want the r value to be calculated by using pure coordinates instead of locations.

I tried the Atan2 functions before and failed (maybe I was doing it incorrectly) and I know this is such a simple question for vJASS-er, thank you.

Tried this but I'm sure this is wrong lol:
  • Custom script: set dx = GetUnitX(udg_u2) - GetUnitX(udg_u1)
  • Custom script: set dy = GetUnitY(udg_u2) - GetUnitY(udg_u1)
  • Custom script: set udg_r = SquareRoot((dx*dx) + (dy*dy))
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
JASS:
function AngleBetweenPoints takes location locA, location locB returns real
    return bj_RADTODEG * Atan2(GetLocationY(locB) - GetLocationY(locA), GetLocationX(locB) - GetLocationX(locA))
endfunction

So..
JASS:
    set udg_r = bj_RADTODEG * Atan2(dy, dx)

You can skip the bj_RADTODEG * if you don't want to convert to degrees and use radians instead.
 
Status
Not open for further replies.
Top