Forum

> > CS2D > Scripts > player rotation
Forums overviewCS2D overview Scripts overviewLog in to reply

English player rotation

7 replies
To the start Previous 1 Next To the start

old player rotation

KagamineLen
User Off Offline

Quote
help i cant get left, l-d and l-u working

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function rotation(id)
	local rot = player(id,"rot")
	if rot > -30 and rot < 30 then
		print("up")
	elseif rot > 30 and rot < 60 then
		print("u-r")
	elseif rot > 60 and rot < 120 then
		print("right")
	elseif rot > 120 and rot < 150 then
		print("r-d")
	elseif rot > 150 and rot > -120 then
		print("down")
	elseif rot > -120 and rot < -150 then
		print("l-d")
	elseif rot > -60 and rot > -120 then
		print("left")
	elseif rot > -150 and rot < -30 then
		print("l-u")
	end
end

old Re: player rotation

Alistaire
User Off Offline

Quote
user KagamineLen has written
help i cant get left, l-d and l-u working

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function rotation(id)
	local rot = player(id,"rot")
	if rot > -30 and rot < 30 then
		print("up")
	elseif rot > 30 and rot < 60 then
		print("u-r")
	elseif rot > 60 and rot < 120 then
		print("right")
	elseif rot > 120 and rot < 150 then
		print("r-d")
	elseif rot > 150 and rot > -120 then
		print("down")
	elseif rot > -120 and rot < -150 then
		print("l-d")
	elseif rot > -60 and rot > -120 then
		print("left")
	elseif rot > -150 and rot < -30 then
		print("l-u")
	end
end


Well you messed up.

> -120 and < -150 isn't from -120 to -150, but everything BUT -120 to -150.

old Re: player rotation

Alistaire
User Off Offline

Quote
long boring way >


more complicated >
edited 3×, last 21.03.13 07:04:20 pm

old Re: player rotation

KagamineLen
User Off Offline

Quote
thankyou

edit: the more complicated code is liked messed up it tells all directions to me randomly im on down but it tells up lol

old Re: player rotation

Alistaire
User Off Offline

Quote
Fixed it, the 22.5 should be 45, since 360/8 is 45 and not 22.5 <_<

Or how I fixed it, with actually good directions, dividing the rotation by 2 and using the ceil from it, so the 45 degrees of "up", are actually up and not leftup + up.

----

Okay ignore that I hate angles.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview