I want to give each player the ability to place models into the game. Each player will see the placement system locally and once the model is placed it will be replicated to everyone else.
What is the issue?
The models have animations and placing them on the server ends up with rough animations, whilst placing the models locally gives smoother animations but it isn’t visible for other clients.
What solutions have you tried so far?
I have tried to place the models on the server side and fire events to all clients in order to play the animation, however I have noticed that the clients are not synchronized which I think will cause issues when there will be more models.
Any ideas are welcomed and I would prefer explanations of mechanics other code. I would like to understand the concept and proceed with coding it myself.
Thank you in advance.
To make a system where players can place models with smooth animations that are visible to all clients, you can use a combination of server-side and client-side logic. Here’s how you can try to implement it
Server-Side:
Placement Logic:
When a player wants to place a model, they send a request to the server.
The server validates the placement request and checks if it’s valid.
If the placement is valid, the server creates the model on the server and stores its state.
Replication to Clients:
The server then replicates the model’s information (position, rotation, etc.) to all connected clients.
This can be done using RemoteEvents or RemoteFunctions.
Client-Sid:
Receiving Replicated Data:
Clients listen for updates from the server regarding the placed models.
When a new model is created or an existing one is updated, clients receive the replicated data.
Local Animation Playback:
Clients play animations locally without waiting for the server.
To achieve smoother animations, you might want to use client-side prediction. For example, interpolate between the current and target positions/rotations to create smooth animations.
I am slightly confused by the local playing of animations. Since I will be storing the models on the server-side, I will have to send and event to the client to tell the client to play the animation, right? And in doing so depending on the network performance of the client one person can receive the event faster than another person leading to desyncs. Is there some sort of method I am missing for playing animation locally?
No clue so far, however I found a method in a different thread which talked about rendering models and npcs entirely on the client and only passing values from the server. I might give it a try however I still have to understand how to properly do that
Here is a link to that thread server-client-npc-movement