Hi, I had the same issue, and had problems to implement the Actor OnHit Event
too. Even with a NetMulticast
Replication, physics was not replicated properly (exactly what you said on kick, etc…).
So I search on the internet why this could happen, and I thing I have understand something, it is the way that movement is replicated through a multiplayer game. I think (I may wrong) physics is replicated in the same way than animation of character, the client send the hit to the server and, waiting for the response, it interpolate where the object should be. Then the client receive the response, make a correction of previous position and transform of the object (the interpolate one) , apply it, send a new hit event, etc…
So to properly do that, you have to implement all of this on your actor, and this would prevent objects going out of sync, I was a little disappointed to have to do all of that, so I have searched further more, make some test, and I found THE Solution, you should inherit from AStaticMeshActor
, it is a base class which contain a staticmeshcomponent, exactly like what you are making, but the physics replication seems to be already implemented. (I have no more problem with the onhit event, and physics).
In your .h:
#pragma once
#include "Engine/StaticMeshActor.h"
#include "UsableActor.generated.h"
/**
*
*/
UCLASS()
class EARTHDEFENDER_API AUsableActor : public AStaticMeshActor
{
GENERATED_BODY()
(.......)
(To properly do that, you should create a new c++ class in UE Editor, I have tried to just change inheritance on visual studio, but the hot reload didn’t work)