vchillll
(vchillll)
February 22, 2018, 10:48am
1
A()
{
if(pressed(space))
print “hiii”
print “hello”
}
tick()
{
A()
}
"Hello"is printed always but “hiii” is printed only on space key press. I want to replicate that to all clients so that “hiiii” gets printed on all clients and server when i press space key on server.
Firefly74
(Firefly74)
February 22, 2018, 11:19am
2
You need 2 methods :
.h
UFUNCTION( Server )
void ServerPrintHiToClients();
UFUNCTION( NetMulticast )
void MulticastPrintHi();
.cpp
Class::ServerPrintHiToClients_Implementation()
{
MulticastPrintHi();
};
Class::MulticastPrintHi_Implementation()
{
print("hiii");
};
your code become :
A() { if(pressed(space)) ServerPrintHiToClients(); }
TIck(){A();}
tick() { A() }
explanation :
Client call localy “ServerPrintHiToClients”
UE send message from client to server
Server execute “ServerPrintHiToClients_Implementation”
Server call locally " MulticastPrintHi"
Server send message to all clients
Clients executes “MulticastPrintHi_Implementation”
i suggest you to have a look here :