Jump to content
  • Advertisement
Sign in to follow this  
Martin Perry

How to control enemy movement

This topic is 639 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

 

Share this post


Link to post
Share on other sites
Advertisement

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

Edited by RenzoCoppola

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!