More Optimized Way Of Doing This?

What I’m doing is highlighting an object by its physical material when I look at it via linetrace. The line trace detects the physical mat and sets a parameter collection value to 1 or 0 to turn the glow on or off. I want the highlight to disable on any objects that Im not looking at.

The way I’m currently doing this is every time an object is hit, it turns off all the other object highlights through a sequence.

I got this working just fine, however I’m curious if there is a more optimized or easier way of setting this up?


blueprint is here

If I understand the problem correctly, this is what the “ForEachLoop” node helps with. You make an array that lists all of those objects, then every time the linetrace finds something new, you use the ForEachLoop to switch off everything listed in the array, then you switch on whatever object is under the linetrace.

(You can also set up the array(s) using tags, then a “GetAllActorsWithTag” node can be used to find all actors that you’ve given eg a “glow” tag to, and add them to the array. Or find all actors that you’ve given the “walls” tag to and store that list as a “walls” array etc.)

Do you mean like this?

This gets the brush highlight to fire, but does not turn off when I look away. In other words, there is no event fired that turns it off. Keep in mind I am determining the highlight by Physical Material not by actor.

I’m thinking something like this

But as you say, this will only turn the glowing thing off when something else turns on, so I’d also store in a variable the thing that was turned on, and whenever the trace finds something NotEqual to what was there last check (ie when you look away without looking at anything else that can glow), then turn off the thing in the variable.
Maybe that helps, but if I’ve misunderstood or it doesn’t apply, well never mind :slight_smile:

That’s a great example, thanks! I don’t think that would work for me tho because every physical material has its own material parameter collection. For example, the walls have their own parameter collection value so that the highlight doesn’t appear on all the objects when the value is set to one (highlight is turned on).

Maybe I need to play around with this a bit more.

It worked! Thanks! This was my first time using array’s in blueprints and I’m sure this is much more optimized for the engine as well! I also have the added benifit of not having spaghetti in my blueprint event graph :slight_smile: