How can I switch between pawns during gameplay?

Hello Prompt please. I’m in the same game 5 pawns, the game begins with a pawn observer I need to click the mouse to select one of these pawns and move it (I did manage pawn) I realize switching to this pawn? and after the movement switch to pawn the second observer mouse click on this pawn? If possible, give an example, I will be very grateful! Sorry for my english :slight_smile:

1 Like

You simply make PlayerController possess new pawn on click

1 Like

Hey Ivanov,

As Shadowriver mentioned, the easiest way to handle this is to make your Player Controller possess whichever pawn you click on. In your Character (or Pawn) Blueprint, you can do something like this:

Then, whenever you click on any instance of this pawn, the Player Controller will switch to that pawn.

Hope that helps!

Ben Halliday

3 Likes

Hey. Thank you for your help. I really helped. But then when I click mouse again to return to the pawn observer. Please tell me if not difficult!

Hey. Thank you for your help. I really helped. But then when I click mouse again to return to the pawn observer. Please tell me if not difficult!

You can do the same sort of thing but using Un Possess instead. The easiest place to do this would be the Level Blueprint, though there are probably more efficient ways to handle it once you get into more complex controls. Place an instance of your Observer Character in the level, and reference it like this:

There are many ways you can do this, but this should help you get started.

Thank you very much. And it is possible to implement with repeated clicking on the pawn?

You mean if you click the Actor while it is already possessed, you want it to return to the Observer? Sure, just set a Boolean variable to true when you possess the pawn. Then use a Branch node off of the On Clicked event to see whether the pawn is currently possessed, and if so, to possess the Observer pawn instead.

Hello Please tell me what I’m doing wrong does not go back to using a pawn of the observer? Thanks for the help!

7723-снимок+экрана+2014-06-04+в+15.48.22.png

7724-снимок+экрана+2014-06-04+в+15.48.40.png

I think part of the problem you are having is that Event Actor on Released doesn’t do what you want it to. The big problem though is that your MySpectator variable is only pulling the MySpectator Class, and not the instance of it in the level. To solve this, you can use Get Player Pawn on Begin Play, and save it as a Pawn variable.

Hope that clears it up a bit.

Ben Halliday

Thank you very much! Everything works. I’m really grateful to you.

The problem I have with all of this is, what if you have a C++ pawn?

That’s a question better asked in the C++ section:

https://answers.unrealengine.com/spaces/23/c-programming.html

This solve my 2 days problem on unpossed!! Thank u !!! Set the variable “Observer” solve it!

1 Like

8 years later I ran into a similar issue and this thread helped me solve it. Thanks!

Same here!