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.
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.
Yeah that's because the game engine doesn't loop 10,000 times per second.
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'
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
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
Yeah that's because the game engine doesn't loop 10,000 times per second.
@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'