Ai networking delay

The ai system I currently have is having trouble keeping up with the player I believe the cause is that the update for client position to server position typically has long delays (the AI is managed on the server)

https://gyazo.com/5bccd8fb059079dd1e4886fa3c5c8867

If I move the player on the server then there is no delay for movement

https://gyazo.com/dc3eed0f7dd78b745496560c04ffafbb

So I was thinking that a solution would be to move the AI based on whoever has control over the network ownership of the AI

I do not wish to create the AI completely client-sided since I am not confident in making perfect syncing while also managing security

This is unfamiliar territory to me so are there any other better methods or concerns that I should know?

1 Like

In your gif it looks like you’re checking the player’s position every x seconds, by other means, after a delay?

I call a function that senses nearby players each frame(stepped) of the game, I think the problem is that I am using a lot of function/method calls

I am using behavior trees for my game which makes use of object-oriented programming, and each object has a :Run() method I believe the current AI is calling 10+ function calls just to move