boomerang maths

hgkjfhfdsj

Active Member
Reaction score
55
hi
im after the maths behind a typical smooth 'boomerang' curve (not sure what the correct terminology is) in projectiles, or otherwise example of spells that uses this. if not, a sketch will do (anything will be appreciated really... )
the standard approach to homing projectile that target a unit in motion produce sharp turns since angle is updated to project directly towards the unit rather than interpolating angles that smooth the angle difference of the original position & the target's new position.

such obvious sharp turns can be observed when the unit uses blink, whereas relatively short difference in angle and distance (<100) wont have any (observable) effects. for example, in the ss below:

SharpProjectile-1.jpg


thanks

EDIT
ignore the knight :p
 

roXplosive

New Member
Reaction score
15
If i understood right what you meant i think in a periodic trigger when you move the unit you should do :
- Save the facing of the following unit (f1 - real value)
- Make it face the target being followed
- Save the new facing angle (f2 - real value)
- check if the absolute difference is smaller than a treshold of say 15-20 degrees and if not make f2 the new facing for the unit
- if it is greater then make the new facing of the unit = f1+RsignBJ(f1-f2)*threshold
 

hgkjfhfdsj

Active Member
Reaction score
55
btw the knight is irrevelant ( i used issued order rather than creating a new abilty)

f1+RsignBJ(f1-f2)*threshold
its this part that i need help with :p explain please?

RsignBJ returns either 1, -1, correct me if im wrong.
whats the maths to make the '1' dynamic/ adjusted to the distance/angle (ie greater angle, greater '1')
 

roXplosive

New Member
Reaction score
15
That would set a maximum change in facing of the following unit . But i don't have the world editor at hand to check if that is the real function ... wait a sec to start it :

JASS:


function SetNewFacing takes unit follower , unit followed returns nothing 
local real f1= GetUnitFacing(follower)
local loc1=GetUnitLocation(follower)
local loc2=GetUnitLocation(followed)
local real f2=Atan2(GetLocationY(loc2)-GetLocationY(loc1),GetLocationX(loc2)-GetLocationX(loc1))
// it matters that the folowed unit&#039;s position isthe base of substraction

if (f2-f1)&lt;20.00 then 
   call SetUnitfacing(follower,f2)
else
   call SetUnitFacing(folower,f1+RSignBJ(f2-f1)*20.00)
endif

call RemoveLocation(loc1)
call RemoveLocation(loc2)

endfunction
 

NBalfa

New Member
Reaction score
10
in triggering you can save the target unit and then set the points in this way
from integer A 1 to x do actions
set y point point offset by z * integer and sth similar for the degrees
 
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