🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to control enemy movement

Started by
2 comments, last by wodinoneeye 7 years, 6 months ago

I am using navigation mesh (triangulated) together with Bullet. In navigation mesh, I find path using A*. This gives me set of "points" inside triangles from navigation mesh. From those points, I create bezier, catmull or other interpolant.

The problem is, how to actually "move" NPC

My ideas:

1) I calculate new position via "dt" and forward vector (or local coordinate system) via derivation in a new point. This gives me correct NPC orientation and rotation, but it kinds of "break" other logic, because I "teleport" NPC from position to position (I have constant update rate, but still... if there is some small / thin Bullet collision body, it may goes through)

2) Use similar approach as for player. Methods like "MoveForward", "MoveLeft", "RotateAroundUp" etc. However, in this case, I am not really sure, how to calculate order of operations from interpolant. I have a current and final position (and orientation) and I need to get serie of "move" and "rotate" operations to get to that final position.

3) something else?

What is preferred solution? And how to potentioanlly do 2). I have beem looking over net, but found different ways, how to do this based on 1) or 2), but none of them was quite descriptive.

Advertisement

I've an idea.
Interpolate agent movement direction vector towards the next path point. Then you select next point in the path.

Typical approach is to just set a movement vector or target location on your NPC's character controller and let it figure out how to actually get there. The path-following code can then poll and adjust every tick. The character controller uses physics and animation systems to move so there's no tunneling and everything looks right. The character controller might also deal with local object collision avoidance (steering behaviors).

Path finding generates a path and sets movement adjustments based on the next closest point. Controller feeds physics/animation. Physics/animation does the actual movement.

The weakness of the approach is that if the physics/animation system _can't_ follow through on movement for some reason, the path finding system may not know about it and try to tell the character to move somewhere it can never go forever. There's various fixes for that situation, but it's something to just be aware of and think about during testing/implementation.

Sean Middleditch – Game Systems Engineer – Join my team!

See if you can apply some LOD (level of detail - by distance or if the object is in the oplayers view) to avoid unneeded processing.

Far away or not visible doesnt require finesse, which you want greatly increase for nearby (ssen) movement.

Depending on how remote you might skip any interpolation between large steps BUT be ready for the possible switchover point where more accurate positioning IS needed.

The enemy AI system may be doing LOS (Line of Sight) determinations which might be useful to control a LOD mechanism.

--------------------------------------------[size="1"]Ratings are Opinion, not Fact

This topic is closed to new replies.

Advertisement