How to select an actor during runtime?

How do I select an actor during runtime? I obviously can do it when the simulation isn’t running, but I want to be able to select an actor during runtime and change its material. I was hoping to do this through a blueprint.

So… how do you want to do it?

  • click on it?
  • bind it to a key?
  • choose it with UI?
  • something else?

I want to click on an actor with my mouse during runtime

I want to click on an actor with my
mouse during runtime

Ideally, this should sit in the Player Controller / Pawn. But that depends what the end goal is. Essentially, since we’re clicking the mouse, one must ensure the blueprint this is in can process input. Regular actors do not, not by default.

Thanks! If I wanted to click a non-player, (say a cube), would the blueprint be any different?

Also, where do I find the “set” function? Is that the full name?

Thanks! If I wanted to click a
non-player, (say a cube), would the
blueprint be any different?

I meant the location of the script, not what it targets. The target can be anything for as long as it’s an actor.

Also, where do I find the “set”
function? Is that the full name?

Set is not a function. It’s a [variable][1]. You can get (read) or set (write to) them:

You can also right-click pins to Promote them - this will create a variable of the correct type automagically.

346833-screenshot-5.png

You need to press on F1 button. After that You can choose anything in the “world outliner” window during PIE (Play in Editor). And You can change parameters of actors.

Or You can do Eject by pressing F8. Then You will can click on actors in viewport

I want to click on an actor with my
mouse during runtime

and

I was hoping to do this through a
blueprint.

Did you even read what OP requested… On the other hand, who knows…

Ah ok, makes sense. Say I added a “Print String”, to the Set variable in the blueprint above. Basically, whenever I click an actor (like a cube) it will print to the output log. Will this print DURING runtime? I know that it will print when the simulation is running, but that’s not what I want.

Will this print DURING runtime?

Yes… why not try it. It takes like 5s.

Image from Gyazo

I did…I can’t see it on the output log.

This is what I have

Wait sorry, this is what I have:

When I try running the simulation, nothing gets printed to the screen OR log.

Oh wait, nvm. I had an extraneous level that pretty much had nothing in it apart from a command to open a DIFFERENT level…once I deleted that and put everything in my main level, it prints to screen.