Author Topic: Deg To Rad not working correctly?  (Read 988 times)

Code: [Select]
yaw(mDegtoRad(180));
I expected that to turn me 180 degrees but instead it only turned me a degree or two. What am I doing wrong? I'm just doing this in the console.

Tested this in my server:

Code: [Select]
echo(mDegtoRad(180));
3.14159

Maybe you aren't using it incorrectly?

The Appendix says:


I'm not sure what this means, but if it helps.

The appendix was the first thing I checked but it didn't help. I just want my player to turn 180 degrees. The command in OP should work but it doesn't.

%rad = %d / 360 * 2 * $pi;
This is the way to doit. mDegtoRad(180) does this correctly. There is nothing wrong with the function.




Try yaw($pi*360*2);
I have no idea why it works

yaw($pi*360); and yaw($pi*360*2); both turn the player 180 degrees. yaw($pi*180); turns the player 120 degrees. This makes no sense to me.


It appears to be that the max value for yaw is between 1335 and 1336.
Anything over that number makes you do a 180.

I feel like yaw() is what's bound to your mouse - use $mvYaw = X instead.
For example, if I remember right, $mvYaw = $pi / 2 turns you 90 degrees.

I feel like yaw() is what's bound to your mouse - use $mvYaw = X instead.
For example, if I remember right, $mvYaw = $pi / 2 turns you 90 degrees.
Indeed it does. It is slightly inaccurate though, after a couple of times it's off by a degree or so.

How do I turn 360 degrees?
Code: [Select]
yaw($mvYaw=$pi*2);Is not working, it only turns 180 degrees.
« Last Edit: November 06, 2011, 01:51:30 PM by Demian »

How do I turn 360 degrees?
Code: [Select]
yaw($mvYaw=$pi*2);Is not working, it only turns 180 degrees.
Do that twice?

Why not just use
Code: [Select]
yaw(180); instead of making it complicated like that...?

Why not just use
Code: [Select]
yaw(180); instead of making it complicated like that...?
Clearly because yaw uses radians

yaw() doesnt use radians

It is a function that converts the magnitude of your mouse movement into a direction for your player to turn.  I have found that it is an exponential scale, and doing yaw(100); three times is not equal to doing yaw(300);

$mvyaw just uses a radian input between pi and negative pi

I do not know alot of default game functions, so I use %rad = %deg * (3.14159265/180);

Indeed it does. It is slightly inaccurate though, after a couple of times it's off by a degree or so.

How do I turn 360 degrees?
Code: [Select]
yaw($mvYaw=$pi*2);Is not working, it only turns 180 degrees.

No no, you don't use yaw() at all, you just set $mvYaw to the value you wish to turn and it handles it.

Example:
Code: [Select]
$mvYaw = $pi / 4;

%rad = %deg * (3.14159265/180);
Torque hates anything that is more precise than 5 decimal places.
It will come out as 3.14159 / 180.

And also, you don't turn 360 degrees. That's an entire circle, you'd end up in the exact same spot as you started in.