HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

SetUnitPosition + SetUnitFacing

01-05-2009, 12:29 AM#1
Beardo
Wierd problem when using these two natives in combination with my movement system. What happens is:

1. After moving the unit via SetUnitPosition, if I "rotate" the unit

Collapse JASS:
(SetUnitFacing(u, GetUnitFacing(u), -+ 10)


its facing doesnt actually change.. but the camera will rotate:

Collapse JASS:
SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(u)
.


2. If I move the unit again via SetUnitPosition, the unit will actually face the correct direction. If it stays stationary, its facing never actually changes. I know it's SetUnitPosition cause if I use SetUnitX and SetUnitY it works 100% perfectly. I like SetUnitPosition though because of how it deals with collison with cliffs and such. How can I use SetUnitPos w/ SetUnitFacing and have it actually work?


I also noticed a wierd side effect of SetUnitPos.. for some reason it will order your unit to "stop" after you've used the function on a unit. This is strange considering my unit has 'Amov' removed. Could this be effecting the SetUnitFacing?

Any help with these questions would be appreciated. Thanks!
01-05-2009, 12:31 AM#2
Anitarf
Quote:
Originally Posted by Beardo
Any help with these questioins would be appreciated. Thanks!
I'd help if I saw any questions in your post.
01-05-2009, 12:36 AM#3
Beardo
edited... there you go.
01-05-2009, 12:42 AM#4
moyack
If you pause the unit, set the facing angle and unpause the unit, it will change the angle.
01-05-2009, 02:27 AM#5
Beardo
Tried it. I can't do that because the units facing is going to be constantly changing as it's moving forward w/ an animation. It screws everything up. is there any other way?

EDIT: Figured out the way around it:

Collapse JASS:
call SetUnitFacing(HERO[i], GetUnitFacing(HERO[i]) - 9)
call SetUnitPosition(HERO[i], GetUnitX(HERO[i]), GetUnitY(HERO[i]))

Then later:

Collapse JASS:
call SetUnitPosition(HERO[i], PolarX, PolarY)
call SetUnitAnimationByIndex(HERO[i], HDA[i].walkindex)