How could I make a serverside npc walk on client side terrain?

  1. How could I make a serverside npc walk on client side terrain?

  2. The issue is I have a terrain generator script that loads in 5000x5000 size, it’s randomly generated, Basically, every time you start a new server it’ll do this. My issue is if you run the terrain loading script in server-side, it will load but will take 8-10 minutes minimum(2k-15k ping during this time). Also, no I don’t want to load it in chunks, It’s not that big. The terrain can load under 40 seconds when client side. Right now my game idea is softlocked to singleplayer because I can’t load enemies in multiplayer since they’ll just fall through map if loaded serverside.

  3. I haven’t thought of a solution for this. I don’t think anything related to this is on developer hub.

Anyways, I’m not asking for much. I’m asking for ideas. My last resort will be making the server script manually control a dummy through fireallclients and that’ll be tough.

2 Likes

I don’t think you can, can’t you code the npcs client sided?

2 Likes

Hello, if you haven’t read the post, I can do that but it’ll make my game softlocked on singleplayer. I’m trying to make it multiplayer too.

2 Likes

My bad, ages ago i implemented a system that used physics and maths to determine on serverside where the npc is currently located client sided, the issue with the system is that it uses set attribute every couple seconds which uses alot of memory, if you want the code i’ll be more than happy to provide it to you.

2 Likes

I don’t mind at all!

but if there really is no other way, I’d need to control the script from the server and do a lot of backend communicating. The server will just verify things, send value, receive and repeat. This could be more efficient than your code since the client will be doing the computing.
Anyway, I’d like to hear everyone’s opinion.

Edit: I might’ve not readt it properly. Did you say the server uses physics and maths to determine where the npc is located in client side? If that’s the case I need something more efficient. But I don’t mind reading your code it might sparkle some ideas

3 Likes

If the terrain is generated locally, doesn’t every player have different terrain ?
Also, wouldn’t it cause problems for people with bad performance devices ?

2 Likes

I guess you should either make it all server-sided, or client sided.

1 Like

If you are generating the terrain through noise like a height map, you can just set the NPC’s height as they walk around by calculating the height of the terrain at their location. For this, you could use alignposition or something.

no, every player will have the same terrain because the terrain generation is based on the same seed the server randomly generates :slight_smile:

Thanks for the suggestion. Though their humanoid state would always be floating, i’m not sure, but I can try it.

Maybe you could disable the falling/floating humanoid states?

Why don’t you just get the first client that spawns to load it? then send that data over to the server to draw the map itself as invisible and each consecutive client can request that data and draw the maps for themself, make sure the server side is inviisble and collideable and the clientside has no collision.

It;'s a hacky solution.