x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I toggle between two Player Controllers

Hi,

I'm building a top down RPG with the top down template that works fine as a point and click game. I would like for the players to be able to choose between a point and click and a wasd/gamepad control system (like playing diablo 3 on consoles) but I am lost as how to do it.

I don't want both to work at the same time, so I thought of making a second Controller BP and then creating an input to toggle the active controller.

I'm simply not sure as to where I should call the toggle (I guess its in game mode?) and what is the name of the node that sets the player controller.

If it's not possible in blueprint, can someone point me to the place in c++ where I can play with this?

Thank you all!

Product Version: UE 4.19
Tags:
more ▼

asked Oct 16 '18 at 03:30 PM in Blueprint Scripting

avatar image

FredPoissant
53 4 9 16

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

There is this but i really douth this will work as this is not what it was intended to do and there only one PlayerController for each player

https://api.unrealengine.com/INT/API/Runtime/Engine/GameFramework/AGameModeBase/SwapPlayerControllers/index.html

You could try switching that controller by switching pawns, that might be a lot easier

more ▼

answered Oct 16 '18 at 06:36 PM

avatar image

Shadowriver
36.6k 932 169 1111

avatar image Entropikz Oct 16 '18 at 07:17 PM

It might also be easier to use a state machine to control the characters input type in one controller. Have one state for top down and then another one for gamepad/WASD. If executed correctly they won't work at the same time. It could get a lot messier managing the game with two controllers.

avatar image FredPoissant Oct 16 '18 at 07:36 PM

Thanks to both of you.

I will try different ways of doing that to see which one fits best.

Also as a bonus I would like to see if it is possible to switch control schemes on the spot by pressing a key from a different control setup, like it does in The Witcher 3 (not made in Unreal) and in Vampyre (made in unreal) if you press a key on the keyboard or mousse and then when you press a key on the gamepad. Vampyre proves that its possible to do it in Unreal but I can't find any literature on their controls setup.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

The way I handle it is that I just have the input events from all types of controllers possible, on the same class, but use enum Switch or Branch to control whether they do anything. So if GamePad is selected as the control type, its Input events will continue forward and do their thing, but if Keyboard is selected then only its input events will continue. They're all going to fire, but only some will get past the initial branch or Select node.

more ▼

answered Oct 26 '18 at 06:46 PM

avatar image

mightyenigma
3.8k 18 20 20

avatar image mightyenigma Oct 26 '18 at 06:47 PM

For this to work, the Input Mappings in your project settings have to map to separate Input events rather than putting the gamepad ones in the same event as the keyboard ones.

avatar image FredPoissant Oct 26 '18 at 08:28 PM

Wow thank you!

That seems like an easy way to handle this! I will surely give it a try!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question