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

[JASS] Formula is imprecise?

Status
Not open for further replies.
Level 4
Joined
Jan 19, 2008
Messages
69
So I'm trying to move this unit in a circular motion and everything is working out perfectly fine apart from one thing, the radius keeps increasing by a tiny amount. Over a short span of time this would not be visible - but this is not the case.

This is the code and the formula for the circular motion that I'm using:
JASS:
set u1 = gg_unit_n001_0000
set u2 = udg_UNIT_Dummy[1]
set x1 = GetUnitX(u1)
set y1 = GetUnitY(u1)
set x2 = GetUnitX(u2)-x1
set y2 = GetUnitY(u2)-y1
set d = SquareRoot(y2*y2+x2*x2)
call ClearTextMessagesBJ( GetPlayersAll() )
call DisplayTextToForce( GetPlayersAll(), R2S(d) )
set a = Atan2(y2,x2)+7.50*bj_DEGTORAD
call SetUnitPosition(u2,x1+d*Cos(a),y1+d*Sin(a))
call DestroyEffect(AddSpecialEffectTarget ("war3mapImported\\BlackKeeperMissileNoSound.mdl", u2, "origin"))
set u1 = null
set u2 = null
 
Level 4
Joined
Jan 19, 2008
Messages
69
I can't see anything wrong with the math ?

Is unit u1 has a fixed position ?

Yes u1 does have a fixxed position.

Save the unit's angle from the center of the circle to a variable, and update that instead.

JASS:
set u1 = gg_unit_n001_0000
set u2 = udg_UNIT_Dummy[1]
set x1 = GetUnitX(u1)
set y1 = GetUnitY(u1)
call SetUnitX(u2, x1 + d * Cos(angle))
call SetUnitY(u2, y1 + d * Sin(angle))

d and angle should be saved globally.

I suppose I'll try that, I'll report back with the results :>
 
Status
Not open for further replies.
Top