Select Actor Via/On Click

Hi!

I already have an Actor-Selector set up, altough it is wired to the keys 1,2 and 3. Since the target platform is a tablet , these numbers need to be changed to Touch (Or Click). The Idea is that when clicking one of the possible three actors (RotationCharacter1 through 3) the game posses this new actor. The image shows what i have right now.

I have tried to use mouse over + click, although i didn’t get it to work at all, and neither has hit under channel (The reason being that i didn’t see a way to convert hit to actor reference).

The Solution:

PlayerController has a “Get Hit Result Under Cursor for Objects”, you can pass it an array of acceptable object types (like Pawn) and then use the “Hit Result” to get the clicked on pawn.

Hope it helps :slight_smile:

Possibly the reason your previous try at mouse over + click didn’t work is because your collision was wrong, “Visibility”.

Try changing that.

Also, to convert hit actor reference, just cast to your pawn BP

(also, would be best to not get cursor hit every tick, just put that part on left click)

Two ways: Drag out Hit Result and “break hit result”, or, right click on Hit Result and split struct pin

Well, everything set up but the Get Hit Result Under Cursor by Channel only has two values, no hit result hit actor. How do i set up one with more options?

With the risk of sounding dumbfounded, what kind of variable should i use? I can’t find a “Hit Result” for the normal pawn-variable.

The variable type should just be actor

That worked, though one final thing, my “Set” of pawn to posses looks like in the attached image, so it is the wrong type. Which type should i use?

38054-namnlös.png

Looks like this text didn’t make it:

“This Is how it looks now, sadly, it doesn’t seem to work, nothing happens when clicking :(”

?

did it work?

Try changing “left click” to “e” or something. See what happens.

If that doesn’t work, use “enable input”.

Is this top-down project?

“Try changing “left click” to “e” or something. See what happens.”

This Worked!! Very, Very nice. Thanks a lot for this!