Auto Pilot Funtion. 8D

Game Editor comments and discussion.

Auto Pilot Funtion. 8D

Postby Sgt. Sparky » Sat Jan 13, 2007 7:48 pm

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
Last edited by Sgt. Sparky on Sun Jan 14, 2007 3:02 am, edited 1 time in total.
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby morcior » Sat Jan 13, 2007 11:21 pm

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.
morcior
 
Posts: 83
Joined: Fri Jan 12, 2007 12:16 am
Location: UK
Score: 9 Give a positive score

Postby Sgt. Sparky » Sat Jan 13, 2007 11:26 pm

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 :(
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron