Rotating object in increments

Posted By: SirCamaris

Rotating object in increments - 01/16/09 23:51

I'm trying to get a player to rotate 90 degrees over 4 equal increments by pressing a key only once. The end result however, is either a full 90 or 22.5 degree turn.

if (key_a == 1) //key_a is pressed

{ while (key_a == 1) //while pressed
{wait(1);} //wait a frame
while (my.pan <= 90) //key_a is released and action is taken
{my.pan += 22.5;} // while my.pan <= 90, increase angle by
wait(1)} // 22.5 then wait a frame
}
Posted By: SirCamaris

Re: Rotating object in increments - 01/17/09 20:38

Hello all,

I was able to figure it out. I had to write a separate function and call it in the action code.

function rotate_left()
{ var new_angle = my.pan + 90;
while (my.pan < new_angle)
{my.pan += 22.5;
wait(1);
{
}

Then within the action...

if (key_a == 1)
{ while (key_a == 1)
{wait(1);}
rotate_left();
}
© 2023 lite-C Forums