Hello,
I have a grid of small spheres (a lot of them), and I want to change their colour/material dynamically as a trigger volume (not the character or pawn) passes through them.
I am able to get this to work with one object at a time (pictured below), but I have 760 spheres, with potentially more on the way and don’t want to manually connect each one.
I’ve been trying to use a ForEachLoop on an array, but I don’t know how to get it to work.
Any help will be much appreciated. Thanks.
Each sphere is a different blueprint?
No. They can be either independent static meshes in the scene or they can be all in one blueprint.
ok, if they are almost the same blueprint you just need to get a referense to it. Instead using the specific actor as the picture above, try the node: “GetAllActosOfClass”, select the Blueprint, from the node drag the “Get” node and then hook it to the target.
Try and let me know pls
I’ve been trying the GetAllActorsofClass, but haven’t been able to get it to work with Set Material. The Array outputs Actors, but the Set Material Target input requires a Primitive Component Reference.
In the picture below, I can hide the objects using a ForEachLoop, but I cannot change all their materials.
I’ve also stumbled across GetOverlappingActors, and GetOverlappingComponents for the Trigger Volume, but I can’t get those to work either.
hmm, now you got me… sorry
I´m having some issues with trigger boxes too, but I have no clue why it is not working once you have already referenced the component…
did you try to drag from the GetAllActorsOfClass, the “get” node and drag it to the set material node to see if works?
So it turns out that my spheres were missing a collision component (when I imported the FBX, collision generation was switched off). Once I added the collision components, things worked as expected.
Here’s the working blueprint:
I did not use an actor blueprint for this. The actors are independent objects in the scene.
You need to enable “Generate Overlap Events” on the Actors for it to work. No need to change any Collision Presets.