Rotation Function Question
Blitz3D Forums/Blitz3D Programming/Rotation Function Question
| ||
im looking for a function that will take the yaw of an entity and give me a number from 1 to 8 of the direction its pointing. Like forward would be 1 then forward right would be 2, right would be 3, ect. . . Ive been trying to do it for a couple hours and cant seem to get it, any ideas? |
| ||
You will ask these questions when I'm at work and haven't got a copy of blitz to check ;) but.. Doesn't yaw go from 0to+180 in one direction and 0to-180 in the other...in which case if yaw>=-22.5 and yaw<=22.5 then dir=1 if yaw>=22.5 and yaw<=67.5 then dir=2 if yaw>=67.5 and yaw<=112.5 then dir=3 if yaw>=112.5 and yaw<=157.5 then dir=4 if yaw<=-157.5 and yaw>=157.5 then dir=5 you get the idea, fill in the rest ;) might come back in a minute to fill them in but it is late ^^ [edit] thinking out loud you could also do something like dir=int(yaw/45) which would give you 0to+4 then -4to0 |
| ||
Something like this:a = 0 Repeat a = a + 1 If a > 180 Then a = -180 dir = ((a+180)/45)-3 If dir < 1 Then dir = dir + 8 DebugLog A+" " + dir Delay 50 Until KeyDown(1) |
| ||
gfk, that works great but how would i make forward be 1 and right be 3 and stuff, it needs to be offset just a bit but i cant get it right. |