Porting AI to Multiplayer

Hello everyone,
I have managed to add multiplayer to my game with the help of a tutorial,
but I don’t know how I should change the AI to work in MP too.
Right now, it accepts a player argument and then makes the enemy walk there.
In MP (on the server), I only have a class which contains player ID, position and rotation. How can I find out which is the shortest distance from the enemy?
My code is on git, as always: https://github.com/Robbi-Blechdose/RPG

Robbi Blechdose

The server needs to know about all players. From there, it’s pretty trivial to check distances (=vector length) between a npc and each player and then have it move towards the closest.
Having no idea how much you know, I’ll add that all maths concerning vectors (and rotations) can be found in the math for dummies tutorial. I love that tutorial… clear and concise and straight to the point.

2 Likes