There’s a handy tutorial here (https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/PossessPawns/Blueprints/) which explains how to possess a pawn using keyboard events. How can I adapt this to use mouse events instead?
If I use LMB (for example), when I click it in-game, all LMB events fire at the same time and I can’t select which pawn I want to possess.
I used the Hit Actor output to Cast to Pawn. Is that ok? It seems to work fine, except for a couple of pawns that aren’t getting possessed, so maybe the issue is with those pawns themselves? I’ll troubleshoot that more later on.
Btw, if the logic is in the Player Controller BP, there’s no need to use Get Player Controller, right?
Looks like I need to learn about raycasts.
Thanks for all the help!
You can simple look for Right Mouse Button, Left Mouse Button or Middle Mouse Button in your Blueprint Editor. You can also take a look this page, where you can define your input on a global level, so everything is in 1 place! Smash the resolve button if that solved your problem or report back! <3
So you want to possess the pawn that you click on. Then you need to use GetHitResultUnderCursorByChannel. You will then use the Hit Actor Output, check if it’s one of your pawns and this will be your pawn reference for the possess node.
The only why it shouldn’t work I can think off, is that something is blocking the raycast. Make sure you are ignoring the raycast on the objects that might be in the way.
And yes, if it’s in the controller, then there is no need to get the player controller. <3
Don’t know if you solved this question after a couple years but you need to make sure that the raycast your doing isn’t looking for a physics object. If so you just need to create one for your pawn