Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Rocket AI Function (DBPro)

Author
Message
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 20th Jun 2006 23:49
This will steer an entity that physically behaves like a flying rocket, or anything that moves by acceleration in a frictionless environment, toward a stationary target. It will not attempt to slow down or stop at the target, but will just pass right through it. In the example the target is the mouse, and if you move the mouse, it will change the direction it is accelerating in such that it goes to the mouse. Also, the blue dashed line is the predicted path that the entity will take as it is flying around. I haven't tested it in DBC, but it should work in it without much modification.



Possible extensions:
It should be possible to change this so that it works in 3d (like a space ship flying around in space). Right now it just iterates, averaging the times of the two dimensions, so averaging the three dimensions wouldn't be much more complicated.

Another possible expansion would be to be able to tell the AI to go through the target location at a specific speed and direction.
Sergey K
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 21st Jun 2006 18:48
nice!

MyNewSite:http://gogetax.com
Forums(About BLO and more):http://gogetax.com/forum
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 21st Jun 2006 19:34
Thanks!

This snippet has the player as a second rocket, and you can try to out-maneuver the AI and get away from him. Also, the AI takes you speed and acceleration into consideration so it is pretty hard to lose. The player and AI have the same turn speed and rate of acceleration. While the AI can always hit a target moving at a constant speed just fine (by using the relative speed between the two rockets), I haven't quite got it to work with an accelerating target, but so far I'd say it does a fairly good job at homing in on you.

lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 29th Jun 2006 05:56 Edited at: 29th Jun 2006 06:05
Here's a little missile commander-like game, but this time the AI defends the city while you attack from above. Click and drag to shoot, or hold the control key to have the computer shoot randomly.

The AI will use the function above to try to intercept and destroy the missiles before they reach the ground.

Every once in a while you'll have a missile that makes it to the ground. When that happens, you're score will increase by 1.

Login to post a reply

Server time is: 2024-11-23 03:19:31
Your offset time is: 2024-11-23 03:19:31