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"

Transfer PlayerState data during seamless travel

Hi! I have alot of problem getting data transfered in PlayerState from my lobby-level to my game-level using seamless servertravel.

1) Host game: Create session ( in GameInstance - Blueprints)

2) Openlevel - lobby ( in GameInstance - Blueprints)

3) Add some values on server side to PlayerState (FString replicated)

4) Seamless travel to Game

 if (HasAuthority())
     {
         GetWorld()->GetAuthGameMode()->bUseSeamlessTravel = true;
         GetWorld()->ServerTravel(FString("/Game/ThirdPerson/Maps/Game"), true);
     }

5) My player state overrides CopyProperties

 void AMyPlayerState::CopyProperties(class APlayerState* PlayerState)
 {
     APlayerState::CopyProperties(PlayerState);
 
     AMyPlayerState* MyPlayerState = Cast<AMyPlayerState>(PlayerState);
     
     if (MyPlayerState)
     {
         MyPlayerState->TestName = TestName;        
     }
     
 }

But then both PlayerStates (InParam and Current) is wiped, ie no values which i had before the travel is set

6) When i debug the existing instances of PlayerStates in the different maps i can see that,

In lobby before semaless travel: MyPlayerstate_2

After semaless travel and in properties i have: MyPlayerstate_4 and MyPlayerstate_5

So, where did PlayerState_3 go? Which problably had my data set

I reproduced this in a from scratch project as well.

Link to project: https://drive.google.com/folderview?id=0B3tss2rB4vfAZUhZUUF2WnFLTmc&usp=sharing

Product Version: UE 4.9
Tags:
more ▼

asked Sep 17 '15 at 07:35 AM in C++ Programming

avatar image

State128
78 4 9 13

avatar image State128 Sep 22 '15 at 06:22 PM

Bumping the post

avatar image State128 Sep 28 '15 at 08:01 AM

Bumping the post :)

avatar image State128 Oct 06 '15 at 12:31 PM

Would really appreciate if some1 at Epic took a look at this. Or how could i get some help otherwise, open for suggestions.

Best regards

avatar image State128 Oct 14 '15 at 12:20 PM

Consider the matter bumped

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Ok, after a second look at ShooterGame i solved the problem, apperently you must set the variabledefinition as below:

 UPROPERTY(BlueprintReadOnly, Replicated, Category = "Preplan")
         TArray<UMinionDataWrapper*> MinionDataArray;    

 void AShooterPlayerState::CopyProperties(class APlayerState* PlayerState)
 {
     APlayerState::CopyProperties(PlayerState);
 
     if (PlayerState != nullptr)
     {
         AShooterPlayerState* ShooterPlayerState = Cast<AShooterPlayerState>(PlayerState);        
         if (ShooterPlayerState)
         {            
             
             ShooterPlayerState->MinionDataArray = MinionDataArray;            
             
         }
         
     }
 }

Think the BlueprintReadOnly is the key here, hope some1else can get helped by this finding,

cheers!

more ▼

answered Nov 14 '15 at 06:43 PM

avatar image

State128
78 4 9 13

avatar image IkarusDowned Nov 16 '15 at 01:39 AM

Hi Slate128, So my understanding of SeamlessTravel is mostly based on this: https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Travelling/index.html

I don't think its the BlueprintReadOnly, but the fact that PlayerState is "persisted" across a seamless travel. You can add more Actors to persist by putting it in the AGameMode::GetSeamlessTravelActorList()

My understanding is that Actors "persisted" across a SeamlessTravel is NOT the same Actor in memory; the persisted actor has its "count" increased (the _1, _13, etc), and certain data is copied across. In The case of PlayerState, there is an existing CopyProperties function which allows you to specify what to copy

avatar image State128 Nov 16 '15 at 10:18 AM

So did you try it out in the PlayerState/CopyProperties? I've read everything there is about this and it still didn't work. I used BlueprintReadWrite on my UPROPERTY and it didn't work, you are welcomed to try it and then we can compare results.

You can persist Actors by implementing GameMode::GetSeamlessTravelActorList() , "putting it" is kind of misdirected as it may be interpretated as to use a Set-function, override is better to use in this case imo.

Cheers!

avatar image lotodore Dec 11 '16 at 06:08 PM

Thank you for sharing the solution. I have the same problem in a blueprint only project and this is really bad :-(. I can override CopyProperties in Blueprint, but it does not work. It will copy the properties, but for some reason not use the copy, as you wrote above. It seems that I need to implement PlayerState in C++.

(comments are locked)
10|2000 characters needed characters left
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