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"

Give specific controller to a specific pawn dynamically ?

Hi everyone,

I have to create an asymmetric game in blueprint. I got 2 different pawns spawning in each level. Each pawn has to have a specific controller because we need different views, controls and characters. So, spawnActor is the answer to spawn a pawn I assume, but as it is a multiplayer game, we're going threw onPostLogin function belonging to our gameMode. OnPostLogin is giving us a playerController ( the default one I think ). How can I change this one dynamically ? Why can't I cast It into my specific player controller ?

Apologize about my english, kind regards. Yaël.

Product Version: UE 4.14
more ▼

asked Mar 05 '17 at 11:42 PM in Blueprint Scripting

avatar image

11 1 1

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

1 answer: sort voted first

The first and simple suggestion would be, try to fit everything you need in the same player controller class and just give them different Pawns.

If that does not work, you need to dive into c++ and create a custom GameMode class. Then override "SpawnPlayerController(...)" or even better "Login(...)" . There you can spawn a specific PlayerController. It helps to take a look at the code in GameMode.cpp to see how it is done, you probably can copy most of the code.

more ▼

answered Mar 06 '17 at 12:45 AM

avatar image

432 12 4 22

avatar image piims Mar 06 '17 at 12:59 AM

First of all thank you for your fast and precise answer ! As both my controller have a complet different behavior, it's hard to mix them up to make only one. Except maybe with a boolean saying am I behaving this way or the other but that's really eurk ugly I'd say ( no offense ).

My entire project has been with blueprint so I don't really know much about how I can instantiate different playercontroller but If there is no other choice I guess I ll have to dive into this beautiful GameMode class :D ! still apologize about the mistakes I can make in english sorry ...

avatar image SteffM Mar 06 '17 at 01:39 AM

I agree, making everything in one controller class can get very ugly, with lots of branches and so. But from all I know this would be the only way to make everything in Blueprints.

It should not be that difficult to make a derrived GameMode class, because you just need to override one method and change a little bit of code. How you determine which player gets which controller is something you need to figure out on your own, but a simple counter should work for the beginning.

(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