Download

How do i spawn an object on the server and show that object to clients connected

I’ve been having a major problem with my code,

Currently i spawn an item on the server and that item doesn’t show to the clients, so i spawn another one on my client but that creates two different instances.
Is there a way(how do i) spawn an item on the server and then show that same item to all the clients connected without spawning separate ones.

thanks :slight_smile:

UFUNCTION( NetMulticast );
void MulticastRPCFunction();

Multicast RPCs are designed to be called from the server, and then executed on the server as well as all currently connected clients. To declare a multicast function, you simply use the NetMulticast keyword:
https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/RPCs/index.html

So make a function that calls the server then the server calls the multicast function which calls it on all clients. :DS-<

If you’re spawning actors, make sure that actor is set to replicate to clients. By default, AActor doesn’t replicate, so in your subclass you might need to set bReplicates to true in your constructor if you’re not subclassing from an actor type that does replicate by default. If your actor type does replicate and you spawn it on the server, it should get created on the clients for you as well.

Thank you, that worked exactly how i wanted.

Best to also make sure it is always relevant or that your net cull distance is setup correctly, otherwise you may still not know that it exists, we just spent about 15 mins “remembering the basics” and I wanted to mention it here in case anyone else comes across this in the future.