How to "Event tick" actor only if is visible?

I want to place a huge number of pick-able items (eg, coins) as actors, every actor have a rotation transform based on event tick.

Is there any way to update pick-able items (event tick), ONLY if actor is visible? This will improve fps a lot, instead doing on “event tick” for all pick-ables.

Thanks!

Updated:
I am sorry but none of the answers solve the problem.

If you ever used CryEngine, every entity have an update policy what you setup when you create the entity and this tells the engine when to call “update”, like if it’s visible, potential visible, never, always, etc. That’s what I need to solve this problem, and I can’t find in UE4 docs anything close to this.

when you spawn an actor to your map, it automatically has it own ticks. Put a flag in each actor when to rotate or not, won’t be much help. Unreal has a level streaming, though. You can divide your map into several mini-maps. Each map will spawn only actors that located in current map.

This does not solve my problem.

This is not currently possible to do in purely in Blueprint. The ability to disable ticking via Blueprint is coming in 4.7 (or 4.8?)

If you want to do this in 4.6, you have to write some C++ code to manually deregister the tick function yourself (setting ‘tick enabled’ alone on a Blueprint actor with an Event Tick node will not actually disable the Blueprint tick):

SomeActor->SetActorTickEnabled(bTickEnabled);
SomeActor->RegisterAllActorTickFunctions(bTickEnabled, true);

where bTickEnabled is whether or not ticking should be enabled for that actor.

You shouldn’t try to do this based on the rendering thread’s visibility culling: an object’s visibility is culled on a per-frame basis and the cost of registering and unregistering ticking functions so frequently would be more expensive than just ticking all the time (typically). Also, culling happens on the render thread, so you’d have to pay a big cross-thread communication cost. So, you should probably figure out some custom logic that works best for your game to determine when to unregister or re-register the ticking functions.

I can’t find any viable way to update rotation on lets say 5000 actors every frame with out killing fps. If there is a possibility to update only visible or based on a view distance those actors, will solve the problem. But checking every frame each actor to see if it’s inside “view distance” will solve nothing. So I am thinking if actors are sorted by culling algorithm, can be easy to update only visible ones.

Maybe some one of UE devs can give me an advice on this.

That’s an idea, I will try this and tell you the result.

Ok, so I’ve put the mesh rotation inside the material, almost the same effect like doing rotation inside the blueprint, except reflections on that object now seems to be broken, and I have no idea how to fix that. So far half of problem is solved.

  • added, reflection and shadow of that object is totally broken now

What are you doing on that Tick? maybe there is way to avoid using Tick

if you want pretty coins, maybe you can live without 5000 in each level? in mario, it took forever to find 100 coins in each level, and you want 5000 coins in a single level?

if you really need that many coins, i would forget about reflections and proper shadows, turn off reflections and shadows, add a blob shadow decal and fresnel rim lighting shader, or just make it glow and call it good enough. if your game involves collecting 5000 coins in a level, i doub’t the player is going to pay too much attention to each coins reflection and shadow quality.

if all else fails, add a sparkle particle effect and a nice sound effect, and it should feel great.

Or, you can create a UObject class that hold all data for the actor including the actor location. Then, you can use OctTree, when the UObject is within your player’s range, you spawn an actor and inject the data into the actor.

Why not make it a skeletal mesh?

Make a simple bone, a single one in 3dsmax or whichever program you use. Make a rotate for 360 degrees in it and import it that way.

You can still make a blueprint of this skeletal mesh with a sphere covering it for collision purposes and picking them up. Since it’s a coin only, you don’t even need an anim blueprint. Just use the animation in Skel mesh panel in blueprint.