Page 1 of 1

Auto Pilot Funtion. 8D

PostPosted: Sat Jan 13, 2007 7:48 pm
by Sgt. Sparky
In a paper airplane game I am Making I have an auto pilot funtion :D, I thaught I should post it for other people to see if they want to make one :D Here is the
Code: Select all
if (Auto_Pilot == 1)
{
    if (angle > direction(x, y, Coin.x, Coin.y)+ 5)angle -= 5;
    if (angle < direction(x, y, Coin.x, Coin.y)- 5)angle += 2;
    if (angle == direction(x, y, Coin.x, Coin.y))angle = direction(x, y, Coin.x, Coin.y);

That is what I have so far, the if (angle == direciot(Ect.) is to stabelise it once it faces the Coin so it will not shake when it faces the coin :D

PostPosted: Sat Jan 13, 2007 11:21 pm
by morcior
the third line doesn't do anything :p

You can remove it.

If the plane is a little shakey, you can increase the buffer zone (currently +or- 5 degrees) - or, better in this case, reduce the angle -= 5 line to a smaller numebr like 1, or even a decimal number.

This will make the plane make smaller adjustments so it has more chance of getting within the buffer zone, currently an adjustment could push it outside the buffer so you'd get "shaking".

Assuming this runs from a timer event, you'll probably want to increase the timer frequency to make it run smooth and have the plane make its adjustments fast enough. Try about 20ms.

PostPosted: Sat Jan 13, 2007 11:26 pm
by Sgt. Sparky
if is on the draw actor event :D but if i put it to one it would take bout 5 secs to do a turn :( that is why I have it on 5 instead on one :D but thank you anyways :D :D :D and for the buffer zone if I have it > 5 or < 5 It will miss the coins it is trying to collect :(