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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Respawn Player after delay [C++]

Hello, I know there are tons of threads like this, but i did everything they were writing in this threads and cant do it. So what im doing: On player death im setting timer to respawn with RestartPlayer after 10 secodns. ( deathmatch) and i cant get right player to respawn. Only server is respawning himself, so i think im getting controller in bad way. I tried it all. (Game is multiplayer)

Product Version: UE 4.20
Tags:
more ▼

asked Aug 24 '18 at 05:07 PM in C++ Programming

avatar image

Znany.eX
17 1 1 2

avatar image mightyenigma Aug 25 '18 at 06:12 AM

can you show how you are triggering the respawn and which classes are involved?

avatar image Znany.eX Aug 25 '18 at 09:48 PM

@mightyenigma

void AScharacter::respawn() {

 APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);

 UE_LOG(LogTemp, Log, TEXT("resp %A"));



 GetWorld()->GetAuthGameMode()->RestartPlayer(PC);
 PC->ServerRestartPlayer();
 GetWorldTimerManager().ClearTimer(respawnhandle);

}

ive tried changing this to getworld and millions of other combinations

avatar image mightyenigma Aug 25 '18 at 09:53 PM

Hmm i only know blueprints but i winder if your default game mode has your character class as its default pawn? if not then i think restartplayer might put tge player into a non character pawn that is more like a spectator maybe

avatar image Znany.eX Aug 26 '18 at 04:30 PM

i Got gamemode override BP_Testgamemode and there i set default pawn. but in GamemodeBase i cant change DefaultPawn ( its gray)

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

3 answers: sort voted first

On every machine including the server, player controller from index 0 is usually just the furst player to be created on that selfsame machine. Player controller at index 0 of the server will not be the same player as you find at index 0 on another client machine, and on a different additional client machine, player at index 0 will be yet another different player.

Since this function you showed runs on the server and it gets player at index 0 it will always get the server's first player and not any of the player co trollers belonging to clients who connected after the server started.

Your code is inside a CharacterPawn child class which means it inherits the vase pawn class' function to get that pawn's controller (i dont knkw what it is calld in C++). But it is a function the Pawns all have. In blueprint it is called just GetController I think. That returns the pawn's controller.

So you dont need to find it you see; the pawn already holds a reference to its own controller. so just Get that and if necessary, cazt to your controller class and then call your reset player function.

more ▼

answered Aug 27 '18 at 01:16 AM

avatar image

mightyenigma
3.8k 18 20 20

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

I will check, but its interesting because i dont think default gamemode got my pawn

more ▼

answered Aug 26 '18 at 04:12 PM

avatar image

Znany.eX
17 1 1 2

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

Ok so i figured out i just need to get right player controller. can someone help me how to do it in multiplayer? iteration?

more ▼

answered Aug 26 '18 at 05:36 PM

avatar image

Znany.eX
17 1 1 2

(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