I searched for several hours a working method to switch my active player controller at runtime with blueprint. I basically just wanto support different control schemes (default and VR specific controls).
Possessing doesn’t work as I am not able to create an instance of my VRPlayerController and and assign it to my Game Mode (there is only a getter for ‘player controller’ defined).
So I tried to manually unpossess my pawn and possess it again with my VRPlayerController, but as have only a class of it and no instance it doesn’t work either…
So, how do set a new player controller as active with Blueprint at runtime?
Are you sure you need to be able to change it at runtime?
There is a function in C++ which does this however most of the time you’re advised against it. I’m not sure if it exists in blueprint as well but it shouldn’t be much of a challenge to expose it yourself.
EDIT: Sorry. I can only say that UnrealScript had this function… not entierly sure if UE4 still allows this.
However if you “simply” want to change between two input methods (e.g. VR and normal) and need the possibility to hotswap them (during gameplay) it might be worth doing both in the same class and simply splitting the behavior via a branch / variable.
If you don’t need the “hotswap” you can load a level with a different gamemode depending on the input you want.
thanks for your answer. I’m not sure if I understood that correctly. Does that mean, that I have to branch every input action node right after the event node? Is there really no simple way to change the input scheme / activate another event graph?
If you have like a strategy game and use lets say 20 buttons and want to change all of them this obviously is quite a bad solution.
But what is the difference between VR and “normal”?
Mainly the camera and maybe the movement. Actions should be the same and different buttons can be defined in the input settings. We’re purely talking about behavior here.
So you’d be with something around 4 - 8 points inside of your input where you actually have differences (at least as far as I imagine it) which should be fine if the majority is the same and you need that hotswap.
I mean changing will always affect quite a lot. Every variable you have will have to be transfered to the new controller and so on.
I use a complet different control scheme in VR, so switching the event graph would be a great help. (In fact i want to use the default control scheme if VR isn’t active with some extra buttons).
So it looks like I have to implement some layer of indirection on my own. Thanks anyway.
I tried that, but that didn’t work. Controls were dead afterwards. I tried also to set my controller class with “Set default controller” and then “spawn default controller” but that didn’t work either.
No. At the end I ended up with one branch per input event like (Move Right → If head mounted display enabled then MoveRightVR() else MoveRight() and calling the event via an interface in different components.