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"

Spawning, and then possessing a character in C++

Hi. I've created a C++ project based off on the Third person template. Now, whenever I try to play in multiplayer (in the editor), my first player possess the third person character present in the level. All the other ones appear as grey spheres, and don't have any player characters attached.

I'm trying to figure out why, and how to actually solve it.

I'm thinking that I should probably delete the player character that I already have in the game, and spawn a character for every player that connects.

How would I go about doing it? This is a very general question, so very general answers are more than welcome. Is my approach correct? If so, how to actually implement it? If not, what else can I do? If you could give me some links to videos or tutorials, that would be very appreciated. Or perhaps, a few pointers on where to look it up in the Survival Game project.

Thanks in advance. Any advice will be helpful.

Product Version: UE Github Master branch
more ▼

asked Aug 24 '16 at 07:02 PM in C++ Programming

avatar image

Lord Northern
20 3 9 17

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

2 answers: sort voted first

Hi Lord,

I believe the reason your other players are spawning into grey spheres is that they are set to have ASpectatorPawn as default pawns. One easy way to test this would be to copy the character which is placed in the level in the third person template. Make a copy for each of the clients you want to load in. In the properties window for each of those pawns, under the "Pawn" tab there is an option to auto-possess by player. The existing character is probably set to player 0. If you have two more clients you want to load in, then you will have to set your new copied characters to player 1 and player 2 respectively. Doing this, you are forcing the clients to possess the ThirdPersonCharacter rather than spawning their own default.

They should load in and possess those pawns.

The other option you mentioned is also pretty easy, and is probably the better way to move forward. In order to have players spawn their own pawn and possess it, go to the Blueprints tab above the PIE viewport, World Override, and set the default pawn under 'Game Mode Classes' to the same character which is existing in the level.

Edit: Realized that since you're using C++ there may not be a game mode blueprint for that template. If you are using a custom game mode, or if the ThirdPersonGameMode is defined in C++. You can set the default pawn class in the game mode constructor.

 AMyGameMode::AMyGameMode(const FObjectInitializer& IO)
      : Super(IO)
      DefaultPawnClass = AMyDefaultPawn::StaticClass();
more ▼

answered Aug 24 '16 at 08:06 PM

avatar image

275 8 9 16

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

Hey. I worked, but my character is actually a blueprint, so I had to create a reference to the blueprint from code. The general idea worked, though. Thanks!

more ▼

answered Aug 25 '16 at 06:51 PM

avatar image

Lord Northern
20 3 9 17

avatar image ZeroParadigm Aug 25 '16 at 11:11 PM

Awesome! Just remember that if you ever rename or move that character blueprint you'll have to update it in code also. If you're using the actual path that is. ;]

(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