Yes, I am. I’ve been studying UE4 Framework from the ShooterGame example and there I’ve seen they use a **ProjectileMovementComponent **for their Projectile class.
Let the Projectile also move on the Clients. So you don’t see lags. If it’s not smooth, then it means the Projectile fights the Client Version and the Server Version of the Location.
Just do the same stuff you do on the Server on the Clients.
PS: Please don’t tag me on every Network thread you create. It’s kinda spamming me already. I check out threads even without tagging me.
So I need to spawn the Projectile on both the Server and the connected clients. This leads me to think I should make a NetMulticast RPC function for the Spawning of the Projectile.
The spawn happens in the Weapon_Projectile class:
OLD VERSION (here ServerFireProjectile_Implementation was a ServerRPC function, not a MulticastRPC)
#1 Spawn the Projectile Replicated on the Server [DONE]
#2 and #3 there’s nothing to calculate. Just setting a variable:
#2 - Calculate the Movement on Client and Server -> ok, I set the Variable both on the Client and the Server #3 -Let the Server replicate his Movement -> ok, I replicate the variable value for all the players
Also, with some tests, I see that SOMETIMES the OnImpact() function is called TWICE: once by the Server (as it always happened before), and once on the Client
I say sometimes because the 90% of the time it gets only called by the Server. And before I had this issue, also it was only called by the Server.
What’s going on? Why is the Client joining the OnImpact() function now? And why my projectile still keeps moving that way?
Yea, I know, OnRep functions are only called by the client.
BY THE WAY
My **OnImpact() **function (which gets called everytime the Projectile impacts on something) SOMETIMES gets called **both **on the Client and the Server.
The 95% of the time, it gets only called on the Server.
What could the reason be for this? I remind you that the Projectile gets spawned ONLY once by the Server
Is the projectile marked as Replicated? If so, a copy will be created on all clients as well. So OnImpact will fire there too.
Now why it’s not consistent (does not always fire on the client) is probably a different issue.
Are you by any chance deleting the projectile at OnImpact? This could cause the projectile to be deleted on the client before it actually hits something.
Yes, it was replicating. But why does the ShooterGame set the Projectile class to replicate?
Since a projectile is created and destroyed on the server, why would one choose to replicate it?
Thus the question arises: should I replicate it?
Yes, the OnImpact destroys the projectile. That was the reason
Depends on what you need. If you want the projectile to be visible / existing on the clients, you replicate it.
For example, OnImpact on clients could be used to spawn some hit particle effect.