• 0

    posted a message on Question about unit rotate- Atan2(x,y) + 180

    @RileyStarcraft: Go

    ok, so I may be become over zealous adding those 0's, as my frustration level went up. I seem to remember reading that the highest frequency it can do is 16ish time a second, but that's still unneeded. The timing I have been using is a 10th of a second, '.1'

    Posted in: Miscellaneous Development
  • 0

    posted a message on Question about unit rotate- Atan2(x,y) + 180

    I'm working on a map where I would like to have a unit turn 180degrees from the direction of movement. The most basic way I can get this working is:

    While Conditions Key != false Actions Make unit face (Atan2(X,Y) + 180) over some seconds

    This trigger does 90% of what I'm looking for. It points my unit in the right direction, but the downside is that its a single swoop; you tap the key one time and it swings the unit around to face 180degrees of its movement. What I would love to have is while the key is down to rotate the unit in smaller bits until it reaches the value of Atan2(X,Y)+180, aka the reverse degree. So far I have run into three issues in my attempts to work this out.

    First, the degree a unit is facing is calculated by angles 0 to 179 and -180 to -1, not completely on a 0 to 360 rotation(unless I'm overlooking something). This is causing me a headache when trying to determine what direction I should have the ship rotate and at what increment I should turn at.

    The second issue is that if I, for testing sake, tell the unit to turn 1 degree over any amount of time, even .0001 seconds on a loop, it takes a rather long time for the unit to rotate to the wanted angle.

    The third issue, I think I'm just overlooking something rather simple and will feel incredibly dumb when someone points it out, I would like to check the current facing angle of the ship and the 180 of the Atan2 in real numbers. This gives a less block/line feel to some of the movement, opposed to parsing to an int. The problem I'm having with reals tho is that if I increment by any whole number I can never get to Atan2+180.

    Does anyone have any suggestions for any of these problems of mine? If I'm not making sense in what I'm trying to do, please let me know and I will try to write it out better.

    -Smith

    Posted in: Miscellaneous Development
  • To post a comment, please or register a new account.