AI unable to catch up to player

Just a heads up, I’m still experiencing issues with this. I’ve been keeping an eye on the thread for the past few weeks but haven’t posted because I’ve been out of town. I’m aware @BuilderBob25620 is working on something but if anyone has any more suggestions please let me know. So far, everyone seems to be more or less in agreement that it’s a latency problem.

2 Likes

It 100% is a latency problem. Without a doubt.

1 Like

Oh, my bad! I had completely forgotten about this! Anyways, like I said earlier, I managed to get it working with lower latencies, but for players with a higher latency you should probably just hand the pathfinding off to their client. Despite the risk of this method due to exploiters, there’s no other way that I know of for high-latency players. Anyways, I’ll clean my code up today and have it ready for presentation by tomorrow.

1 Like

UPDATE: Truly sorry I won’t be able to present this today. I broke my collar bone earlier today and as a result, all projects of mine, including this one, have been put on hold until I can type without pecking the keyboard. Again, truly sorry. I’ll have this as my first priority once I am healed enough to not do damage. I still had a few things I needed to get cleaned up, but if you want me to just post what
I have now and try and try to get it working yourself then just say so and I can.

2 Likes

That really sucks, hope you get better soon. Take as much time as you need; I’d rather you post it when you feel it’s complete so that I don’t have to spend time trying to figure out the incomplete parts when you already have them figured out but just can’t implement them because of the injury.

In the meantime, I’ll try to find other parts of the game that I can work on that don’t rely on the success of the pathfinding.

2 Likes

Oh my gosh, I’m having the exact same issue! I’ve spent the last 8 hours trying to fix it and now my script is real messed up… I hope you can find an answer to it because i do not want to make my AI slower than the player (no point of a sprint system otherwise)

Please @ me if you figure out a solution because I’m stumped at the moment too

Also hope you get better soon @BuilderBob25620!

2 Likes

I have surgery tomorrow, so I should be able to finish this sometime next week, after I get caught up on homework.

The solution is all about monitoring the players latency and assembly velocity and then adjusting from there. I actually became stumped at one point when trying to get the prediction for the characters estimated position, but I recently found the solution for that from another project I was working on.

2 Likes

Don’t stress yourself dude, I’m in no rush, and I might be ok with a bit of lag now that I’m adding the jumpscare code. So it might not matter that much, at least for me.

Also you sound like an absolute genius in coding and a great person!

Hope your surgery goes well, and that you’re back in good health soon :yum:

2 Likes

Don’t worry. I’m not so much stressed as I am engrossed. Also, I don’t think I worded the bottom paragraph correctly. What I meant to say was it will help me estimate their position for greater latencies.

2 Likes

This isn’t a client server latency issue. It happens to ai as well I made a helper NPC to kill ai zombies and the same issue occurs still.

1 Like

I don’t have too much time and I’m away from my computer so I can’t test it, but isn’t there a delay with pathfinding? I’m pretty sure that computing a path yields the thread until a path is returned. I’m unsure how long that takes (I usually write my own pathfinding scripts) but that could be at least one source of delay. Might be too fast to notice though.

Try making it so it goes directly towards the player if you’re within a certain range of them to see if that fixes it.

Server-based entities will still have to deal with server to client latency of course, but this might be able to reduce the overall latency maybe.

I managed to make a script that solves this issue

That’s already what the system I’m making does. However, you did bring up a point that I missed, about pathfindingservice yielding until a result is ready to be returned. I had forgotten about that, so perhaps I can redesign part of my system to incorporate this.

What if you did something similar to TweenServiceV2 aka handle movement in client and verify on server?

That way, the npc will be able to match up to the player while also being mostly consistent between all clients since server verifies the position every second or so.

Alright, here’s the result of my work. It isn’t perfect, but it’s at least functional. For me that is. Let me know if it works for you.

https://www.roblox.com/library/9386031202/Pathfinding-Dummy
And here’s the module you need to use with it:
https://www.roblox.com/library/9386023524/EasyPing
You should put the module inside of ReplicatedStorage.

So I don’t know if I did something wrong (I placed EasyPing in ReplicatedStorage and the dummy in the Workspace), but unfortunately, it doesn’t seem to be working at all. If I don’t move, the AI will run off to the right seemingly indefinitely. If I move, it will pathfind pretty well sometimes and momentarily catch up to me before floating mid-air trailing behind me and other times won’t pathfind at all and will instead just travel in the same direction I’m traveling. I’m not sure what could be causing this because I don’t know enough about the material. The fact that it appears not to pathfind at certain points makes me think it’s something to do with the pathfinding script, but I’m not sure. I’m not getting any errors from what I see.

Has anyone else tested the pathfinding dummy? I’m hoping this is just something on my end because I don’t want to push @BuilderBob25620 any further with their injury if it’s still an issue. The EasyPing module is definitely useful and I’m sure could also be used for other purposes in game.

Don’t worry. I’m doing better now and have regained full use of my limb (at least for typing). Still not allowed to lift anything above 5 pounds, but other than that I’m good.

What seems to be the issue? Also, now that I think about it, I only tested this in studio. I can test it later in a running game instance.

Yes, I’m planning on releasing it as a community resource once I finish the documentation and tutorial.

1 Like

I posted about the issue earlier in the thread and a brief recap is that the AI seems to be acting completely randomly and with total disregard for the scripts you wrote. I wouldn’t worry about the difference between studio and a live server because I’ve only tested everything in studio so far. I followed your instructions about what to place where to the best of my understanding. Am I forgetting something?

Eh. I guess I’ll do some more in-depth testing. Also, what is you are ping while in-game?