HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Setting Structure Facing Angle

03-28-2009, 01:18 PM#1
fX_
(I am posting this for background for a submission.)

Setting structure facing angle cannot be done by just SetUnitFacing(); it requires the following operation:
Collapse JASS:
SetUnitFacing(structure, angle)
Wait(t)
SetUnitFacing(structure, angle)
where t is a function of the absolute angle offset between the structure's initial facing angle and the defined angle to which its facing will be set. If t is not waited - if there is no wait or the wait is shorter than t - the structure's angle will not be set to the defined value; it will be set to a value that is at an offset from the initial angle less than the offset of the defined value from the initial angle.
By experimentation, the time t1 it takes to set a structure's facing angle to a value offset by 180.00 from its initial facing angle is 0.75; and the time t2 it takes to set a structure's facing angle to a value offset by 180.00 from its initial facing angle is 0.75/2. So t is a linear function of the offset and, by calculation, t is expressed by the offset: t = offset/240.

Note that t is linear to the offset but the change in facing angle for every change in offset (or t) is not linear to the change in offset (or t) - I don't know why. The change in facing angle decreases through time.

Precluding any of the steps will cause failure.

Furthermore, although this operation will indeed set the structure's facing angle to the defined value, it will not be shown in-game by the model of the unit; the model's facing angle will remain as it was initially. So, in addition to the above operation, the structure's model must be refreshed by hiding it:
Collapse JASS:
ShowUnit(structure, false)
//then show it again if you like
.
03-28-2009, 04:51 PM#2
Bobo_The_Kodo
So does this mean you could do something like this:?

Collapse JASS:
function SetStructureXY takes unit whichUnit, real x, real y returns nothing
    call SetUnitX( whichUnit, x )
    call SetUnitY( whichUnit, y )
    call ShowUnit( whichUnit, false )
    call ShowUnit( whichUnit, true )
endfunction
03-28-2009, 05:22 PM#3
fX_
I have tested only adjusting facing angles; don't know about positions.

edit: if you mean will refreshing like in the method above work with adjusting xy values:
refreshing is independent of the effect actually occuring. you can refresh it but if the change didnt occur in the first place, then nothing will change after u refresh.
03-29-2009, 02:56 PM#4
Anitarf
So, why is that wait necessary? What are the results with a longer/shorter wait or without it?
03-30-2009, 01:14 AM#5
fX_
Quote:
If t is not waited - if there is no wait or the wait is shorter than t - the structure's angle will not be set to the defined value; it will be set to a value that is at an offset from the initial angle less than the offset of the defined value from the initial angle.

Quote:
Note that t is linear to the offset but the change in facing angle for every change in offset (or t) is not linear to the change in offset (or t) - I don't know why. The change in facing angle decreases through time.
03-30-2009, 10:19 AM#6
Toadcop
game constants ? set it to -1
idk what is the problem to set building facing angle.

+ about building changing position... have some one tryed to add movement speed to the building and after change the position ? + afaik the pathing texture will be on the same place at all.
03-30-2009, 08:03 PM#7
Weyrling
Quote:
Originally Posted by Toadcop
game constants ? set it to -1
idk what is the problem to set building facing angle.

+ about building changing position... have some one tryed to add movement speed to the building and after change the position ? + afaik the pathing texture will be on the same place at all.

The RP map SotDRP makes every building have movement, and simply removes the 'amov' ability from the structure when it is created, causing it to be unable to move.
This allows you to change the angles of the buildings at will with the simple 'Set facing'.