Pong Online

Hi,

I was trying to do a 4 way Pong game with UE with multiplayer online (not local) but got some issues:

-Anyone know how to make the ball bounce correctly for clients and server because if I simulate physics its not always replicated and bounce at different directions. Is there anyway to make the ball bounce without simulate physics everytime it hits the paddle player and replicate?

-I need to spawn players bottom, top, left and right but I need them to axis lock different so they can only move up/down or right/left depending where they spawned, it is possible? I tried to put a blocking voluming to make players only move where I want but it got some issues for corners where the blocking volumen merge.

Thank you in advance!

The problem with physics on client side is, that latency and other factors can result in the physics to behave differently on every client.
One of the “easier” solutions is to just disable physics on this object on the client, so that only the server does the physics and the movement of the ball is replicated from the server. The downside is, that clients might notice their latency more and the server-player (if any) has an advantage.
An other solution is to keep physics enabled, but constantly update the position/movement from the server. However, that might still result in crazy effects. You’ll have to figure out what works better for your situation.

Question 2:
Since you have an upper limit of players, you could create an collision channel for each of them, so that you can place and control the blocking volumes for every player separately (in the collision detail settings for the volume actor).
Custom Collision Type

You can also make your PlayerController configurable by keeping a few booleans which enable/disable input in certain directions, so that you can configure each player differently when the game starts.

Thank you a lot for the tips I will try to disable physics on client and make the server update only to clients and will add some box triggers on each spawn point to activate some booleans for the movement.