Highlighting objects one at a time

Hi all,

I am fairly new to UE and blueprints. I spent a few days trying to figure out this issue with no luck.

I am working on a simple mouse interaction with actors being highlighted on click. I did get it to work, but now the previously clicked on actors remain highlighted when new ones are clicked. I need them to de-highlight if a new actor is clicked on, so there is only one highlighted actor in the scene at all times.

Please see my component blueprint:
(the upper part is with on hover interaction and it works just fine, but the park with on lick and material switch does not behave the intended way)

Please let me know if you have any tips on how to fix it!

You’re setting the material when an actor is clicked on, but you need to unset it as well to return it to it’s de-highlighted state. To do this, have a variable on the character that holds a reference to the actor they clicked on most recently. After the character clicks again, call a function on the previously clicked on actor that resets the material.

hi @Simple_Binomial
thank you so much for the tip. I tried to understand what you mean and made a different version ( the blueprint below is in mouse controller, not in character or component) but it still does not seem to work. I’ve been trying different things but nothing seems to work.
Can you please how do I call a function on a previously clicked actor?
Thank you so much!

Remove the bottom left mouse event, including attached nodes.

In the top left mouse event. Remove the first branch (unneeded). BEFORE you set Testvar, do TestVar.isValid, if true, reset the material on it. Then set TestVar to the hit actor and set material like you have above. Make sure you have the fail output on the isvalid connected up to the exec on set TestVar so it will set it even if you dont have anything set yet.

1 Like

hi @Countsie
thanks a lot! It works now!! really appreciate your help!

1 Like

No problem :smiley:

Hey @Countsie sorry to bother you again. I am trying to re-make this blueprint but now using linetrace by channel instead of hitting under cursor ( I need to be far from the objects I am clicking on). I have updated the blueprint but now it changes material only under cross hair (not under the cursor). Can I remove crosshair all together and enable cursor interaction with linetracing? My blueprint:

Thanks a lot!!

Look at these functions:

Edit: Actually you probably want to use this: