Jump to content
  • Advertisement
Sign in to follow this  
teremy

NPCs/Computer Enemies in Online Games

This topic is 1247 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

Hello.

 

I managed to write my own "reliable UDP" network protocol, so my basic game already works ( a bomberman clone ). What I want now is to have monsters, or enemies in general, on the map. Some of them may be passive ( just walking around ) whereas others may follow a certain player when within range.

How exactly are those kind of enemies handled?

Clients send move requests and the server answers with the position, is the server also constantly telling the clients the new positions of other enemies/npcs? I wonder how this is done in games like GTA, where there are a lot of npcs walking around on the map.

Maybe there is a cheaper ( regarding network traffic ) solution instead of just telling the clients the new positions as with normal players ( the other clients )?

 

Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Typically, yes, the server will send the clients the "truth" about enemies.

The logic for what an enemy does may be co-simulated deterministically on each client, too, with occasional corrections/updates from the server, depending on the specifics.

Note that, if an enemy always follows the closest player, this will be different on different screens (unless you run everyone behind with a round-trip command latency,) so the server likely needs to at least send out "currently, enemy X is following player Y," and maybe more occasionally send out "and enemy X is at position Z with direction/orientation/velocities W."

Share this post


Link to post
Share on other sites

Since you wrote your own reliable protocol you also know how to make a parallel non-reliable protocol/stream within its mechanism.

 

For object location updates which can quickly become obsolete it can improve efficiency to have certain message types be shortshrifted on how 'reliably' they are transmitted (like short term resend then give up past an expiration time or if superceded by another message of the same specification (like an objects revised position).

 

Certain messages have to be reliable (key one-shot events) but many dont have to be.

 

Of course this complicates the ties between the application and the message transport, but you probably want to investigate that anyway (eventually) for some kind of traffic throttling adaptibility (for when the network slows down, then simulation traffic is simplified temporarily to avoid sending packets which probably (in the detected degraded traffic situation) will resend over and over wastefully).

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!