I have a multiplayer question.
If a client spawns an actor only for itself (not visible for the server), this actor has no collision, because the server does not recognize that there is a collision.
Is there a way how I can spawn the actor with the collision only for the client?
I am currently working on a similar chunk system as in Minecraft. A world is generated around each player (Spawn Actor from Class). But the server can not generate all areas of each player that would be a performance disaster
But the problem is, if it doesn’t do that, every client falls through the floor.
If a client spawns an actor only for
itself (not visible for the server),
this actor has no collision, because
the server does not recognize that
there is a collision.
That makes no sense.
Regardless of whether an actor exists of the server, locally or both, if it has collision geometry it will collide with whatever is loaded on the application instance. In fact, a lot of questions we get here, regarding physics movement in a multiplayer environment are to users not setting their collision authority correctly and their actors are colliding on the server AND client causing the objects location data to fight with itself.
I would start off by checking your mesh actually has collision geometry, and check its collision settings (enabled, blocking, channels etc).
It could also be that the spawned actor has a collision setup on the client, but the object it is colliding with (let’s say the floor), which is owned by the server, might have collisions disabled on the client, meaning the locally spawn actor has nothing to collide with.
Throw some prints on the begin / end overlap / hit events for both objects (locally spawned and server spawned) and see what comes out.
Thank you for your reply.
But currently I have exactly the problem.
When the client spawns an actor for itself and he tries to jump on it, for example, it seems for a short time that he is standing on it, but the server then notices that the client is in the air and puts the client back in front of the object on the ground. Since the server is boss, the client can spawn whatever it wants as long as the actor does not exist in the server, no collision exists.
So far I have understood it like this.
In my case the floor consists of these spawned blocks.
If a client spawns a floor it simply falls through. If the server has to spawn a floor for the client, the server would always have performance problems. So my question would be if there is a way for the client to spawn the floor without falling through and without the server having to spawn the floor for him?
I now understand more of your problem.
If you are using natural replication with physics that would be the case. The simplest solution would be to spawn the object on the server (so the server knows about its collision) and then just make the mesh visible on the owning client. This way the server and other clients won’t see the object, but still knows there is a collision there.