Download

Replicating OnCompHit

Replications very tough for me to get my head around. I’m working on a simple Air Hockey type project and have got both the server/client movement functioning and replicating. My next step is replicating the way I add forces to the Puck, I have an offline working OnCompHit function that knows when I’m hitting it softly vs hard and it looks great. I’ve tested and made sure that its getting separate and correct info when it comes to how hard on both the client and server and this to seems to be working.

Here’s a short clip of my issue that might help understand. You can see the “Client” “Server” tags at the top of the windows. https://youtu.be/7jErF2yAEX8

Here’s some code snippet. I have tried handling this OnCompHit from the Players Class aswell converting it so it all works of course. Both version hold the same result so far.
Also tried (Server, Reliable) Unreliable with validation etc.

I would really like to get a function replicated through code properly if anyone has any info or more questions I’m here. Thanks for your time.


Trying some more stuff due to advice still no go/sameish result.

You don’t really replicate thing like this.

Standard way is, client hit test then RPC to server, with validation;

Validation implementation on the server is a second hit test, server side, to validate the hit test performed by the client.

This is where I’m at right now. Still only the server able to have an impulse effect so not replicating properly. Il keep digging, Any advice would be great. Thanks for replying.

Okay so big shoutout to **BrandonSkyfire **for tutoring and walking me through this one, I got the behavior I was looking for in the end. Here is the refactored code and a short video of the result.

https://www.youtube.com/watch?v=4ywEQaz8-LQ&feature=youtu.be

I’d be very careful with that, it has very high potential to hammer the network with packets and/or get the client kicked - especially since they are reliable. Hit events can get easily spammed.

Since the physics simulation is running on the Server as well - the server is the one who should be in control of the physics state of objects. Clients should be treated as “dumb terminals” that just receive the state from it, not tell the server what to do.

Yeah turned out it doesn’t work with any level of latency, At a loss at how to figure it out.