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"

Does the Server tell the client to spawn?

Hey guys, read some information on the AGameMode You can read here...

Assuming everything went well, AGameMode::PostLogin is called. At this point, it is safe for the server to start calling RPC functions on this PlayerController.

So I have also looked the Shooter Game example GameMode and I've very confused to how the Server Spawns the incoming connection.

 void AMyServerGameMode::PostLogin(APlayerController *NewPlayer)
 {
     GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Black, FString(TEXT("Got player")));
 
     Super::PostLogin(NewPlayer);
     AMyPlayerController* NewPC = Cast<AMyPlayerController>(NewPlayer);
 
 }

So I tested this, and on my dedicated server, I do get two "Got Player". As the server I have that client (who joined) I have their Player Controller.

Now do I tell the player controller (Server calls to owning client) that "Hey spawn a pawn in this location..". Or as the server, do I spawn a pawn first, then tell the player controller to posses it?

Product Version: UE 4.9
Tags:
more ▼

asked Mar 29 '16 at 08:52 PM in C++ Programming

avatar image

Moynzy
219 19 18 25

avatar image mrooney Mar 29 '16 at 09:21 PM

So this is kind of a guess just based off of how other spawned actors work.

The server definitely spawns the player's pawn on itself in RestartPlayer on the GameMode with SpawnDefaultPawnFor. I think, if it uses similar stuff to how other replicated actors work, the server adds it to the networked actors list, which then gets replicated down to the clients, and then the clients will spawn it for themselves locally and then initialize it with the data from the server, which I'd imagine would include the possessing controller.

That's an educated guess, but I'm not very certain about it at all because there's a lot of special player spawning functions to do with spawning client players, but I can't tell if they're just to spawn players in specific situations other than arbitrarily for all cases.

If you want to check for yourself put some breakpoints in your constructors/postinitializecomponents/Possessedby functions on your player class and launch your game with the debugger attached to the client.

avatar image Moynzy Mar 29 '16 at 10:08 PM

I liked the comment, thumbs up. Would have reply soon, but Anime.

So, from your comment, the server spawns the actor/pawn (which is replicated) meaning that clients will spawn a dummy actor/pawn in parallel with the servers.

So as you said, if the server has the players controller from post login, the server will use that controller to posses the pawn, which means the client will do the same thing, theoretically.

Cheers, time to implement this :D

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

0 answers: sort voted first
Be the first one to answer this question
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