Hi!
I’m trying to get my blueprint communications sorted here, but I can’t for the life of me figure out how to achieve what I’m trying to do.
The two base concepts behind what I’m trying to achieve
-
I want things in the game to run on a specific interval (or multiples of that interval). That is, rather than running updates in the world every tick, I want to run them every 1/35th of a second. This is not a problem in itself, I have a working implementation. It does however require that every object placed or spawned implements the timer in their Event Tick.
-
I want to have most (if not all) of my map objects that aren’t map geometry to inherit most functionality from a master blueprint. I’m not gonna outline all functionality here, but two quick examples would be that the master has (amongst many others) two booleans, “Pickup” and “Floatbob”. If you check “Pickup” on the child blueprint, it implements the relevant behavior. If you toggle “Floatbob” for the child, the actor will float up and down in the air. Or for that matter, have a useless barrel map object, check a boolean for it being “Solid”, and have it do nothing else than being an obstacle.
The problem
The dealbreaker right now is that, essentially, every map object uses their own Event Tick to calculate (with the help of delta seconds) if a 1/35th cycle has occured and do stuff then. Sure, most modern computers could probably handle the load without problems, but it is still bad from an optimization perspective.
I eventually started wondering whether or not I could do this in the Gamemode’s Event Tick, and have it fire a custom event for any map object which “may care” so to speak. So, a map object with the “Floatbob” flag checked would care in order to sync its animation with the 1/35th cycle, however, the aforementioned barrel object wouldn’t recieve it… it doesn’t care.
What should I do?
I’ve been looking at other questions, tutorials, etc., and it seems what I am looking for are Event Dispatchers. However, I am unclear on how I would be using them. Looking at the Content Examples (iirc, it was the Blueprints - Communication, 1.4) it uses the Get All Actors of Class function. Tying that up with the calculation in the Gamemode’s Event Tick would also seem expensive.
Is there any way to achieve what I’m trying to do? Could anyone walk me through the process?