I have a dedicated server and I want to send a packet to all clients, invoking a function on the client side, with some parameters contained in the packet, e.g. dmg taken, who did the dmg, etc.
Look at the code snippet below, when the mob is MeleeAttacking I want this information to be sent to all clients, so they can trigger a melee attack animation. Is there a simple function to do this, e.g. something along the lines of a function:
ServerSend(ClientFunctionNameToInvoke, MobID, Dmg)
Here is my code snippet:
// Note that ticking is only enabled on the server and while the mob is in combat
void AMob::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
float DistanceToTarget = FVector::Dist(Target->GetActorLocation(), TargetPosition);
if (DistanceToTarget <= MeleeRange) {
HitTarget();
// SEND PACKET TO ALL CLIENTS, THAT "TARGET" IS HIT FOR "X DMG" BY "MOB Y"!
}
else {
MoveToTarget();
}
}