How to make Tick only on server

I have a few classes where I don’t need the tick to happen on the clients just on the server.
Is there anyway where I can disable the tick of actor that are replicated on the clients?

Obviously I can use


Role == ROLE_Authority

in the tick function but I am not asking about that.


PrimaryActorTick.bCanEverTick = (Role == ROLE_Authority);

should do the trick I believe.

That wont work. I have tested something similar to this though. Basically when the constructor is called, there is no concept of client or server present at that time.

Will it work to set ticking to false in the constructor and then conditionally enable it in BeginPlay or another initialization routine?

It should work when set up in the BeginPlay() method. It doesn’t in constructor because the engine constructs only a CDO (Class Default Object). Then, when creating actors of this class it uses it as a template.

1 Like