Basic : Character Rotation tied to arrow keys

Started by
2 comments, last by DMonaghan 20 years, 3 months ago
I have a model character that i am trying to get to move around using the arrow keys. forward and back are working fine. for left and right, I want the character to rotate in either direction, and not strafe. I have the strafe working also. I am not tying the character rotataion to the mouse, only to keys I assume something like below should work, however I''m getting a wobble and unusal rotation....... Can anyone help thanks TURN_RATE = 10.00 vec3_t axis[3]; // x[][][] , y[][][], z[][][] // turn if (self->player->cmd.commands & PC_LEFT) self->player->axis[1] += TURN_RATE*self->car->deltatime*0.001f; if (self->player->cmd.commands & PC_RIGHT) self->player->axis[1] -= TURN_RATE*self->car->deltatime*0.001f;
Advertisement
what you are doing is adding a scalar to axis[1] (???).

what you want to do is rotate your facing and right vectors around your up vector.

[edited by - Ghwerig on January 14, 2004 7:15:14 PM]
Assuming you know what you''re doing with that code, the only explanation I can think of is if your variables are too different (in terms of powers, i.e. 0.01 vs. 1000), you might be having issues with float precision. Why do you have to multiply by 0.001f?
I just started out with managed direct-x and found this page on character movement:

http://216.5.163.53/DirectX4VB/Tutorials/DirectX7/IM_Character.asp

Regards,
Robin

This topic is closed to new replies.

Advertisement