Networking: The variable is not set from the client

Hello Desfrau,

I you are almost correct. What you need to make sure that the TakeDamage function is ALWAYS called on the server. Also make sure that the actor who is calling the TakeDamage() function is owned by the client. Ownership is very important here.

What you could do is:

In Fire functionality:


if(HasAuthority())
{
TakeDamage();
}

In my project I approached it as follows:

  1. Get Start, End vectors in client side, and pass them to the server to perform a trace.
  2. While executed on server, I check if the trace hit something (I’m still on server) so I hit somebody, so I call the TakeDamage() on server ALWAYS
  3. Inside the takedamage I execute the TakeHealth() which just substracts the Health variable which is set as replicated

That’s a HitScan approach, for Projectile you could do simply get the firing direction and pass it to the server to spawn projectile.

Anyway, make sure you are executing TakeDamage() on SERVER