Global Variables for every Blueprint scripts?

I made some asteroids prototype with around thousand of asteroids and it was for mobiles, so optimizations were important.

Best way is to place logic/code directly inside actor , and run it 4-5 times per second. Most actor interactions may be that slow, you will not notice difference, that stuff does not need to be processed every tick. Make parent class with this code, then inherit from it.

To do it we made dispatcher that had integer (just integer counter +1 every dispatcher trigger) sent over to all actors. Then actor had random number in range 0…49. If integer from dispatcher modulo 50 was same as random number from actor it performed its logic code.

So every actor run code every 50th dispatcher call, or we split all actors in 50 groups. With this (and inheritance) you can even improve all that and give different range for random int and modulo operation, so different types of actors can run at different nth dispatcher trigger. Like some every 50th other every 20th call etc.

Then having dispatcher game could monitor FPS, and trigger that dispatcher faster or slower.

3 Likes