[HELP] RTS Style "Selected Object" Blueprint

TL/DR: I want to make it so that when I select a tile it becomes highlighted, and then when I select another tile it un-highlights the previously selected tile and said ‘another’ tile becomes highlighted instead. Can’t figure it out for the life of me. :frowning:

Hey everyone, I’m fairly new to Unreal and only just barely working things out.

So long story short I’m working on a top-down tile based game, where the player controls a character via the tiles on a playing board. I have set it up so that when the mouse hovers over a tile it highlights it by changing it’s material, this is working all fine. But now I’ve created a select function using Event ActorOnClicked, which again works fine. When I click on a tile it toggles the material, showing it’s being selected and deselected. However, I want it so that when you select one tile and then select another the previous tile will automatically be deselected. For example, when the player clicks Tile A it turns orange. When the player then selects Tile B it turns orange and any other tile(s) that were previously selected turns white. That’s the kind of thing I want, but I can’t figure it out. Any help would be amazing, thanks.

This is the blueprint I have made so far if it’s any help.


Bump, any help would be great.

You would need to have a variable that has the actor instance of the last clicked actor. When you click on on it (the above ActorOnClicked Event), set that variable to this actor.

Then, add a new branch to check if the clicked actor = the last clicked actor, if not, change the material on the last clicked actor before switching the material on the newly clicked actor then set the newly clicked actor to be the last clicked actor.