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 to change Default Pawn before level loads?

Is there a way to change the Default Pawn in Game Mode for the Player Start before the level is loaded? I'm working on a multiplayer game where each player can select a unique character, and then when it switches from the Select Screen level to the battle arena level, it spawns the selected characters. However this only works for every player except Player 1, who is stuck with the Default Pawn regardless of which character they actually selected.

Product Version: UE 4.9
Tags:
more ▼

asked Aug 05 '16 at 07:19 PM in Blueprint Scripting

avatar image

KanidaAvintar
6 1 2 2

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

2 answers: sort voted first

Set default pawn to none for all.

Spawn the various player classes that are selected and then have the player possess that spawned character.

more ▼

answered Aug 06 '16 at 04:57 AM

avatar image

thankstipscom
654 39 38 72

avatar image KanidaAvintar Aug 07 '16 at 09:41 PM

Didn't work. I set the GameMode's default pawn to none, spawned the four characters and and set all four controllers to possess each respective one. However, Player Controller 0 throws an Accessed None error. It look as if it's still trying to spawn the Default Pawn, and because it's set to none it is getting confused and not even getting to the possess command.

avatar image thankstipscom Aug 07 '16 at 11:13 PM

I'm not sure. cuz I do it differently. But I don't think you want to be using Player Controller 0. Are you spawning the actors and possessing them from the GameMode BP?

So you're doing something like "get player contoller index 0" casting to player controller and then using that to possess?

I don't think getting players at indices are very reliable in multiplayer. Create a custom player controller bp as a child of Player Controller.

Every player will have their own player controller BP. As a server function, spawn and possess inside the custom player controller BP.

I create a custom GameInstance as well. This is where I set the Char selection int. Because the Custom Player Controller is wiped each time the player dies. If you store variables in here. they will get cleared out. GameInstance variables persists so you can respawn them with the same selected character.

Then cast to custom game instance from the Custom Player Controller to get that Int. Then switch on int to tell which char to spawn and possess.

alt text

mpspawnpossess.png (136.1 kB)
avatar image KanidaAvintar Aug 11 '16 at 09:00 PM

So dumb question, but how do I get these custom controllers into the level so that I can spawn the characters? Spawning them as actors doesn't seem to work, the gamemode only creates one type of controller, and create player doesn't offer an option.

avatar image thankstipscom Aug 11 '16 at 09:32 PM

in your project settings in maps and modes, change the player controller to the custom player controller to "use it".

You'll still spawn the characters as actors but do it inside the custom player controller and possess it from inside there as well.

I dont have time right now to simplify it but just try on your own. 1. create custom player controller as a child of player controller 2. set your game mode to use the custom one in the project settings 3. in the custom player controller spawn the character actor and then possess it 4. work on adding different characters later for now just get it to work with one

Each player will have their own version of the custom player controller. You only have to MAKE one. but they'll each get a copy. hence you need to pipe an int variable into it when they join the game to tell their copy of the custom player controller what character number to spawn. In your char select widget you can have that cast to the custom game instance and set the character number there. Then from the custom player controller cast to the custom game instance and get the char selection int and use that to decide which character actor to spawn.

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

Make sure you are creating the Player Start actor inside the Persistant Level (click on view -eye- button and see if it vanishes with persistant level to be sure). I solved it by doing that and deleting other player starts.

more ▼

answered Jun 27 '17 at 08:14 PM

avatar image

Deamonpog
16 1 2 3

(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