[Closed] Run some logic only on client?
How can I run a chunk of code only on the client? E.g. in the tick function in an actor I have some code that is completely unnecessary to run on the server but still needs on the client.
asked Sep 12 '14 at 01:36 AM in C++ Programming
The question has been closed Sep 14 '14 at 02:43 PM by undercover for the following reason:
The question is answered, right answer was accepted
Wrap your tick code in this:
or to avoid checking every tick, start a timer function that runs with the required frequency only on clients, by using the above code to start the timer only on the client.
YourGame.h must be using Engine.h instead of EngineMinimal.h to see GEngine (Epic please fix this, have to tell all my customers this)
Here's all the macros I use to do these tests, you could stick this in a .h somewhere or in YourGame.h
Follow this question
Once you sign in you will be able to subscribe for any updates here