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"

Change PlayerController on runtime?

Hello,

I wan't to change the PlayerController that ist controlling the Player character dynamically. The reason is, that I have 2 different Player controller, one for Wiimote input and one for Xbox input. The selection of the PlayerController happens before the level loads in the main menu. I can't combine the two PlayerControllers into one, because the one for the wiimote uses a mouse pointer, while the xbox one doesn't.

I am struggling to find a solution, any help woul be appreciated.

Product Version: UE 4.11
Tags:
more ▼

asked Aug 01 '16 at 10:38 AM in Blueprint Scripting

avatar image

KArlk.
3 1 2 4

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Hello, KArlk,

As far as I know, there is no way to change to a different player controller or game mode within the same level. But if you are going to load your level after you know which controller you want, then you use the "Open Level" node and use the "options" input to select a new game mode to load with it, overriding its default game mode setting (the arguments are: "?game=/Game/SomeFolders/yourGameMode", no quotes). You would have two game modes, each one pointing to an alternate game controller, and you would load the same level but with a different game mode depending on the option you chose.

You could also load one of two alternate levels and set a default game mode for each one, but loading with arguments will let you do this without keeping track of a useless duplicate.

Remember that on every level load, you get a chance to change game mode too, with all that it is pointing to (but changing a game mode implies a level loading). Also, remember that if you are casting to the game mode now you have two different possible classes, so take that into account.

If you don't want or can't do that, you can also change the properties of the player controller on the fly.

So you can fire some event on it that will set different properties to true or false, depending on what you need (for example, you could enable or disable click events, or things like that).

The thing is that other blueprints that expect events fired by the things you disabled won't work properly. So you would need to make those functions fire from custom events instead, so they become independent of those properties of the playerController that you want to turn on or off.

And then, on the playerController, you can listen to your two alternative methods of firing that action, and then cast to your player pawn and fire your custom event when either is detected. So the functionality remains the same, independent of what is enabled or not.

You can also have a bool that keeps track of which one of your two alternative functionalities are enabled at a given moment.

Hope this helps. All the best.

more ▼

answered Aug 02 '16 at 08:02 AM

avatar image

Diego_Visualma
586 13 10 34

avatar image KArlk. Aug 03 '16 at 12:13 PM

Thanks for your extensive answer. At the time I didn't realise you could just enable and disable the mouse cursor in the PlayerController BluePrint, wich was exactly what i needed. So I didn't have to have two different Player Controllers in the end.

But I might try your approach with the options on the "Open Level" node, as that sems to be a lot cleaner than just having the logik of two input methods in one player controller.

Thanks!

(comments are locked)
10|2000 characters needed characters left
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