Replication System

I made a pretty cool replication system. I use it for projectiles. In order to make everything appear incredibly smooth, the projectiles are simulated locally. However, I would still like to control things on the server with a lot of freedom. This left me with a dilemma. I solved the problem by creating server projectiles that replicated each of their properties to the clients, which then updated their client projectiles with each property. This included things like position and velocity, so that no matter what the server was king of the situation. This whole solution allowed me to avoid awkward situations like the server and the client disagreeing on when a projectile hit a target, and allowed me to leave virtually all logic on the server (where it should live). Anyways, hereā€™s a video showing it in action. Try to note the times when the projectiles seem to ā€œchopā€ as their position, velocity, and color are corrected by the server. Oh yeah, and buddy and garnold got involved while I was testing so yeah. I explain stuff in chat to them too, so if you care you can listen to what Iā€™m saying. Videoā€™s probably overly long.
[video width=425 height=344 type=youtube]KvNFC8EqrQ4

1 Like

Iā€™d like somewhere to test this out.

Yeah, I sent a friend request since itā€™s private.

Reminds me of something I did in a murder game I was helping with. When the player throws the knife, for example, the server raycasts and does damage instantly. It then tells the clients to simulate a flying knife that flies towards the point on the part it hit.

Ended up looking very, very nice. If you ever do something like that make sure to add an arc.

Iā€™ll friend anyone who posts here.

Yep sent a friend request, looks awesome

Do you instantly apply the effects on the client or wait for server input? (sorry, I TL;DRā€™d :()

Iā€™d like to take a peek aswell :3

Not a problem. Because itā€™s not computationally expensive (the way Iā€™m doing it), the projectile conforms every renderstepped.
In writing this, I realize that Iā€™ve defeated the purpose of it. Wow. So, Iā€™m gonna go fix this and see if I canā€™t make it better. Lol. Wow.

So I have fixed it. It actually like looks better now. It looks almost perfect, to be honest. Take a look at this video, recorded live on the server:

All logic is handled on the server. All of it. The client just does what the server says.

1 Like

New stuff: when it is a playerā€™s character, the server puts as much power as is possible in the clientā€™s hands so that the characterā€™s jump is as smooth as possible. The server, on the other hand, handles moving the minions. The power of this replication system to make smooth but legal projectiles is astounding. Video:
[video width=425 height=344 type=youtube]znKl6AT2JNg

Wow. That is really smooth, I understand that you worked hard on it. But could you tell a little bit about how it works behind the scenes. Like how do you handle the Client / Server tasks that smoothly

I can guesstimate what is, so here I go:

When the client does something particle-related, the client instantly starts displaying those particles in a predictive manner - that is, they predict where theyā€™re going to be for when the server sends updates about its position.
The server calculates where the projectile/particles really are and every so often tells the clients where they really are, and some other useful information. (such as heading direction, rotation, etc)

This way, the server is authoritative over the projectiles/particles while the client still sees them nicely and doesnā€™t get any input lag.

Sent a friend request; Iā€™d like to try this

Finite basically hit it on the head.

My local system has some logic on it ā€“ it has a local simulation of the physics on its end. Essentially, if the server updates were ridges, then the gaps between those ridges are ā€˜filled inā€™ by the local simulator.

I use objects I call ā€˜replicatorsā€™ inside of an object in ReplicatedStorage. A replicator is created for each projectile, and the clients detect when a replicator is added into this object. When that happens, it creates a special local projectile which copies all data from that replicator as often as it changes, including position and velocity.

A replicator is essentially a container for a bunch of *Value objects. The local projectile watches for changes on that while simultaneously performing its own calculations.

This is interesting and everything and can be used in many situations, (the best one I can think about is correcting player movement) but when it comes to projectiles, if the server and client have the same mathematical function that controls the position, wouldnā€™t they virtually be the same? That is, if they are giving the same parameters.

Sent friend request.

I sent a friend request! This looks very cool!

[quote] Finite basically hit it on the head.

My local system has some logic on it ā€“ it has a local simulation of the physics on its end. Essentially, if the server updates were ridges, then the gaps between those ridges are ā€˜filled inā€™ by the local simulator.

I use objects I call ā€˜replicatorsā€™ inside of an object in ReplicatedStorage. A replicator is created for each projectile, and the clients detect when a replicator is added into this object. When that happens, it creates a special local projectile which copies all data from that replicator as often as it changes, including position and velocity.

A replicator is essentially a container for a bunch of *Value objects. The local projectile watches for changes on that while simultaneously performing its own calculations. [/quote]

So basically you use a modified version of how Halo Reach does it? Neat. I also use a similar networking strategy in my games to make sure that the client has no perceived input lag.

[quote] Reminds me of something I did in a murder game I was helping with. When the player throws the knife, for example, the server raycasts and does damage instantly. It then tells the clients to simulate a flying knife that flies towards the point on the part it hit.

Ended up looking very, very nice. If you ever do something like that make sure to add an arc. [/quote]

That is genius. What did you do if the knife hit somebody else on itā€™s way towards its goal?
@OP is also a genius.