Change a character using UMG button

Is it possible to select a character by using a button created within the UMG? I have 5 characters, all of whom are set out within the level when the game starts.

The idea is that the player will be able to select a character, move it, and then select another character to move, either to join the previous one, or go off in another direction. I could setup an option to click upon the character model and possess each character individually but this wouldn’t work if the other character(s) were out of view. By using a UMG button I would be able to select a character even if one is out of visible range.

I’m looking to create the game using touch input rather than a keyboard so my options for using a key select for a desired character are not an option.

I have built the buttons but I can’t seem to find an option to interact with my character models within the button’s graph/blueprint.

Any help would be greatly appreciated as I’m not at an impasse that is holding up the rest of my games development.

Barry

Use a variable to keep track of which character is currently being controlled. When you click a button, it changes the value of that variable. Based on the contents of that variable, a different character can be controlled.

If you’re using real-time character controls, put the character control code / blueprints into the controller object. The controller object should control the character. Using possess code / nodes you can change which pawn or character the controller is currently responsible for controlling.

If you’d like to give some screenshots of your character control blueprints or your code then it’ll be easier to give more specific implementation help.

Thanks for getting back to me.

It present I’m making use of the TopDownController from the default templates which at this time controls just the default ‘PlayerStart’ character.

I have four test characters in the game at the moment which consists of a ‘PlayerStart’ node and three characters dropped into the scene. At the moment they are BulldozerCharacter (a repeat of the PlayerStart), Bulldozer2Character and Bulldozer3Character

I’m using the TopDownGameMode which references the BulldozerCharacter as the Default Pawn Class.

When the game is in ‘Play’ mode I have three buttons in the scene which are ‘Ch1’ (Character 1), Ch2 (Character 2) and Reset. These are only for test purposes - more would be used in the final layout.

As I say, my aim would be to have it so that the player taps/drags on the screen to move the character around at the time of playing the game but when they want to change character, they can tap on the button to select another.

This is to be aimed at young children so it has to be kept simple. I did initially plan to have it that the characters were tapped on but of course this doesn’t work when they go out of view of the other models. At the moment, the setup is that each character (vehicle) has its own camera on a springarm.