Sign in to follow this  
CuppoJava

Writing a bot to attack my plane.

Recommended Posts

CuppoJava    164
Hi, I just finished my missile tracking system, and I got very good ideas from this forum. I thought that the missile code can carry easily over to the bot, but apparently not. It would be cool if someone could offer a few tips. The player controls a plane, who has variables Position ( x, y) Direction (theta) Velocity (v) Angular Velocity (theta_v) and I want to write a bot that chases the player. The bot has the variables Position (x,y) Direction(theta) Velocity(v) Angular Velocity (theta_v) The only two variables that the bot can directly manipulate is: Angular Acceleration (theta_acc) Acceleration (a) both variables can have a value of (a specified positive constant, a specified negative constant, or 0) If anybody can point me to a few good links, or even give me a search term that I can google for it would be very helpful. Thanks a lot.

Share this post


Link to post
Share on other sites
dodecahedron    152
angular velocity is a little ambiguous as you use it, since it normally implies a central fixed point is given. I suppose that you mean the rate at which the heading of the bot accelerates.

Here's an idea, but to make it simple, just move at maximum speed to intercept.

To follow in open space:

1. Compute Distance between player and bot.
2. Compute time t required for bot to move to player's point.
3. Compute position p of player after that time t assuming constant velocity.
4. Compute smallest trajectory for bot to arrive at position p in time t.
5. Set bot along trajectory

Share this post


Link to post
Share on other sites
CuppoJava    164
Thx for your reply dodeca.
Yea my terms are a bit ambiguous, here's a bit more clarification

"Angular Velocity" (theta_v) - is the rate at which the bots heading changes.

so theta_v = (change in theta)/time

and "Angular Acceleration" (theta_acc) - is the rate at which the "angular velocity" changes.

so theta_acc = (change in theta_v)/time

As for general outline you gave me it was very clear.
For steps 1-3 I can carry it over from the missile code, which calculates the intersection point of a plane and a missile (if there is one).

But once I know which point I want to get to, how can I manipulate theta_acc to get the bot facing in that direction?

The hard part is : I need to increase angular acceleration to get the direction to start changing, then I need to decrease angular acceleration when i'm close to the desired direction so that I have a theta_v of 0 when I reach my desired direction. (I don't want to overshoot).

Do you have any tips to offer on that?

PS: Is there a general term for what I'm trying to do? like "motion control" or something, so that I can google it?

Share this post


Link to post
Share on other sites
tolaris    288
Quote:
Original post by CuppoJava
The hard part is : I need to increase angular acceleration to get the direction to start changing, then I need to decrease angular acceleration when i'm close to the desired direction so that I have a theta_v of 0 when I reach my desired direction. (I don't want to overshoot).

Why not use the very angle between current direction of the bot plane and the 'intended' direction ... as some kind of a scalar/limit cue for the bot..? E.g. if the angle exceeds say, 45 degree, allow the bot to set turning speed to whatever top value is. (scalar for top turning speed is 1) As the angle crosses this threshold and starts getting closer to 0, have the scalar for the top allowed turning speed slide towards 0 as well, and have the bot adjust accordingly.

Share this post


Link to post
Share on other sites
Erik Rufelt    5901
i hope im not misunderstanding here but this is how i would do it if i got your question right =)

u have a point (bx,by) where the bot is located, and a point (px,py) where the bot should go
u also have an angle (ba) where the bot is heading
now what u need is an angle (pa) to where the bot should be heading



the bot angle u already know, the target angle (pa) u can calculate knowing the x and y of the vector (px-bx,py-by)

when u know that, u just adjust the angular acceleration to something like
if(pa > ba)
acc = +;
else if(pa < ba)
acc = -;
else
acc = 0;

and maybe u should smooth it or something when it gets closer, but u can start with that and tweak it i would think =)

EDIT: and i guess u need to check if the angle is close to 360 so that it doesn't turn a whole turn just to move from 359 to 1.. and take the closest path

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this