maybe openSteer could be interesting for you !?!?!
look at the bottom of this side: http://abusoft.angelcities.com
there is the verry interesting flies demo and all links !!!
Give each node a speed vector and add that speed vector to the nodes location each fixed time unit. You apply thrust by having an accelerate vector that you add to the speed vector each time unit if thrust is being applied.
Example:
Loc{0,0,0}
Speed{0,0,0}
Accel{0,0,0}
Create a timer thread that ticks at a fixed interval and call a timer function.
Timertick
{
Speed = Speed + Accel;
Loc = Loc + Speed;
}
ApplyThrust(vector thrust)
{
Accel = thrust;
}
Now when you give it a thrust vector the object while change speed.
And when you are not adding thrust it will coast along at a constant inerta.
Let’s walk through a few ticks.
State:
Loc{0,0,0}
Speed{0,0,0}
Accel{0,0,0}
Apply thrust vector of {0, 0 1} (and keep the thrust button down for a few ticks) just to keep it simple.
thanx for your help, but i dont really understand what you mean.
the movement of the spaceship is working, but not like i want...
it flyies directly to the target and do not fly curves.
how do i program that the KI should fly curves to reach the target?
this is my idea:
find out the degrees between target and npc-node.
if degree is more then 180 then rotate left (nodedegree=nodedegree+1)
if degree is less then 180 rotate right (nodedegree=nodedegree-1)
and move forward permanent in the new direction (with new degrees)
but i have no idea how to create that in a c++ code.
can you help me for that please?
Get a vector to the target and normalize it. Use this as your thrust vector.
Each timer tick the targeted thrust vector (with a magnitude of one) will add its thrust to the inertia of the ship and the ship will appear to curve toward the target and accelerate toward it until striking it. This is how a heat seeking missile guidance system works.