I am making a rotational space shooter that involves two human players flying around in an infinite 2d world shooting up enemy space ships (bots). I will have 2 virtual cameras and make it a split screen setup. I have done bots before, but not anything as complex as this. Any ideas how I could create bots that will follow the players and point in the right direction? I don't know how I could detect if the bots are pointing towards the players or not. Any ideas would be very helpful.
Haha I made a particle system like that a year or two ago.. it was beautiful
The arctan method is flawless for directional stuff, I was young and rebellious so I decided to make my own following function... while it didn't actually follow the goal perfectly it made for some interesting random misfires and sort of made me feel like my particles had character =)
aaaaanyway what i'm trying to get at with the above vague story is perfect bots are boring, spice them up with some mistakes and they will be well loved.
On another note, what library are you using for graphics and control and such? OpenGL, SDL, SFML, platform specific stuff?
I use Allegro because it is the only graphics library I currently know. I find it to be straightforward and easy to use.
ne555, your talking about comparing one objects direction to anothers right? I need something that can take two points, and tell one point which direction it needs to go to get to the other point. I think Bazzy's formula does this. I will graph it out on paper and see.
Well you may want to look into vectors, rather than having instant rotation you can have inertial rotation, which is an awful lot cooler than simple direction finding.
Also why graph it? Why not simply run a program implementing the functionality?
It is fairly straightforward, but so are the rest. Alright done with my input, good luck.
The problem was that dy/dx is a truncated integer division.
Once you get the angle ( θ in the equation above ) you can make still make smooth/random turns by slowly changing the bot direction instead of setting θ as the new one. There's no need for vectors.
Cartesian coordinates + local polar velocity should be quite simple to implement