Adding player angle with normals

Posted By: Stansmedia

Adding player angle with normals - 08/14/07 06:37

I seem to suck at it, apparently. I'm trying to get an entity to move around with zero gravity, but on certain angles it stops turning and is super sensitive. Probably those crazy angles working me over again. Heres the code:

Code:
 
vec_set(temp3.x,nullvector);
vec_to_angle(temp3, normal);
vec_set(temp3.pan,my.pan);
// Adapt the player angle to the floor slope
temp3.TILT = 0;
temp3.ROLL = 0;
temp3.PAN = -MY.PAN;
vec_rotate(normal,temp3);

temp3.TILT = -ASIN(normal.X);
temp3.ROLL = -ASIN(normal.Y);

temp4.TILT = ANG(temp3.TILT-MY.TILT);
temp4.ROLL = ANG(temp3.ROLL-MY.ROLL);
vec_scale(temp4.pan,0.5);
c_rotate(my,temp4.pan,ignore_me);


Posted By: Captain_Kiyaku

Re: Adding player angle with normals - 08/14/07 13:49

Are you walking on a sphere or something?
Propably a Gimbal Lock Problem.
Posted By: LogantheHogan

Re: Adding player angle with normals - 08/14/07 15:39

Yes. Probably. So, somewhere in your movement function place these lines:

player.pan = cycle(player.pan,0,360);
player.tilt = cycle(player.tilt,0,360);
player.roll = cycle(player.roll,0,360);

And see if that helps whatsoever.
Posted By: Stansmedia

Re: Adding player angle with normals - 08/14/07 19:56

It stops working when i place your code in, logan. Ugh. I find myself fighting this same problem all the time. :'(
Posted By: Stansmedia

Re: Adding player angle with normals - 08/16/07 20:54

I cant get the object to roll to the correct orientation, or go upside down.

If gimbal lock was a small animal ide punt it like a football as hard as i could. This is driving me insane.
© 2024 lite-C Forums