delayed reflexes for AI tank drivers
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
After that, when surprise wanned, its just a matter of light speed lag. (Which in you case would be minimal.)
Don't forget that turrets have some maximal speed for rotation. (It could look weird if you'd forget it) Majority of current tanks are using assisted targeting, so rotation of turret isn't the problem. (and they could hit at 1.2 km quite reliably.) For crew it's just matter of selecting something on a computer screen, or line it with a targeting optics.
As your problem of don't lining up with a target, it's problem of your engine, or you created the algorithm too primitive. I'd say you would find the solution faster than you can read it on this forum.
void Update(float frameDelta){ // this works great by approaching the target // but if the frameDelta is large, then it will skip past desired angle in a step and never line up with the object if (currentAngle < desiredAngle) currentAngle += speed * frameDelta; // clampage - we wont go past with this code if (currentAngle > desiredAngle) { currentAngle = desiredAngle; Fire(); }}
My own developments seem to support that premise. My AI and in fact the stepping of the entire game world occurs at a fixed rate of 15 Hz. I essentially have removed framerate from being a factor. The appearance of smoothness is achieved by interpolation between the two most recent positional states for all visible objects.
If someone has a crappy (must be really crappy) system that runs the game below 15 FPS, the AI and the world STILL get updated at their required 15 Hz. That right there gets you the predictable AI behavior you need for aiming.
Anyone with an engineering backgound and knowledge of discrete-time systems can appreciate the benefits and ease of a constant rate for system calculations. My AI aiming is based on the concept of proportional-derivative control and it really makes for some convincing AI with minimal computation. You can easily dial in coefficients for overshoot, to control how sluggish your AI responds, and how accurate it is.
A P-D control style approach for horizontal aiming is basically:
TurnForce = A * AngleToTarget + B * (PreviousAngleToTarget - AngleToTarget)
or possibly:
TurnForce += A * AngleToTarget + B * (PreviousAngleToTarget - AngleToTarget)
A and B can be determined using trial and error.
Quote: Original post by InnocuousFox
On each itteration, check the system clock to determine how much time has elapsed. Then, apply the rotation rate to that time delta to determine how far it can/has turned.
Thats really bad advice, because different entities in the world would be running at different time frames. The entire frame should be running at the same time step each logical frame.