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"

Destroying actor after server travel crashes game.

Been scratching my head over this one and can't seem to figure it out. This is what I'm trying to achieve: 1. Select character in the lobby 2. Seamless travel to the game level 3. Assign the selected characters.

So the player selects his character while in the lobby. When the timer runs out, I do this:

FString mapsPath = TEXT("/Game/Maps/") + mapName; bUseSeamlessTravel = true; GetWorld()->ServerTravel(mapsPath);

A question at this point - Am I supposed to explicitly mention which players to take over to the next map? Like I keep seeing GetSeamlessTravelActorList pop up every now and then but I'm not sure how to use it.

Anyway, doing this successfully takes me the actual gameplay map. Once in there, I call this function in the GameMode class, which spawns the selected character, assigns the controller to this character, and destroys the old, default one.

void APGameMode::SpawnCharacterSelections() { APawn* CurrentChar; APPlayerController* CurrentController; TSubclassOf Selection;

 for (FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator) {
     CurrentController = Cast<APPlayerController>(*Iterator);
     if (CurrentController)
     {
         CurrentChar = CurrentController->GetPawn();        
         CurrentCharacter = CurrentController->GetOwner();
         Selection = Cast<UGameInstance>(CurrentChar->GetGameInstance())->GetSelectedCharacter();
         //CurrentController->UnPossess();

         //CurrentChar->SpawnDefaultController();
         FActorSpawnParameters ActorSpawnParams;
         ActorSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;

         APCharacter* SpawnedCharacter = GetWorld()->SpawnActor<APCharacter>(Selection, CurrentChar->GetActorLocation(), CurrentChar->GetActorRotation(), ActorSpawnParams);
         CurrentController->Possess(SpawnedCharacter);

         CurrentChar->Destroy();
     }
 }

}

Now, I'm testing this in standalone mode, and the game crashes about 30-40 seconds in the level. I'm not sure what's happening. Lobby and the game level have different game modes, could that be the reason? Although if that were the case, I'm not sure how that explains these observations : 1. If I do everything the same and just don't destroy the default character, the game doesn't crash. 2. If I destroy the default character/actor (CurrentCharacter in code), the game crashes as soon as the level after lobby is loaded 3. If I destroy the default Pawn (CurrentChar in code), the game crashes about 30-40 seconds later.

Don't know what's wrong, any help or a nudge in the right direction will be greatly appreciated. Thanks!

Product Version: UE 4.20
Tags:
more ▼

asked Nov 27 '18 at 07:52 AM in C++ Programming

avatar image

hussainAbis
25 3 9

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

1 answer: sort voted first

Any log data maybe?

more ▼

answered Nov 27 '18 at 08:59 AM

avatar image

ndelchen
297 8 12 17

avatar image hussainAbis Nov 27 '18 at 09:20 AM

Thanks for taking the time out! Here it is

paintgame.log (617.4 kB)
avatar image ndelchen Nov 27 '18 at 09:25 AM

Can't find any crash in there, you sure this is the right one?

avatar image hussainAbis Nov 27 '18 at 09:30 AM

Yeah it is. When it crashes, I get this message: You do not have any debugging symbols required to display the callstack for this crash.

When I look inside the Game\Saved\Crashes\ folder, this is the one that was updated at the time of the crash, so I believe it must be this one.

avatar image ndelchen Nov 27 '18 at 09:37 AM

Check out the Game\Saved\Logs folder, and look for the one that was created at the time of the crash. I usually look at the logs in there, not sure if it makes a difference though...

avatar image hussainAbis Nov 27 '18 at 09:48 AM

Here is the one in Game\Saved\Logs folder

paintgame-2.log (116.0 kB)
avatar image ndelchen Nov 27 '18 at 09:52 AM

Better! ;)

APSprayWeapon::Tick() [h:\github\stanion studios\undertow\paintgame\source\paintgame\private\weapons\psprayweapon.cpp:74]

Check out this line in your code. You're game is throwing a EXCEPTION_ACCESS_VIOLATION. I guess you're trying to access a nullpointer somewhere.

avatar image hussainAbis Nov 27 '18 at 10:22 AM

Ooh yeah I see that and I know what the issue is now. The gun that the default character is holding doesn't get destroyed with him and that references its "OwningPawn" in the tick function. I tried to implement a fix right away but it goes a bit deeper - that reference, and is going to take some time, so I just thought I'd pop back in here and thank you for all the help. That almost certainly is the root cause. I really appreciate you taking out the time, I had been stumped over this for quite some time :) cheers

avatar image ndelchen Nov 27 '18 at 10:28 AM

You're welcome, glad you were able to find your problem :) Make sure to check your log files in the future, they can help you save a huge amount of time! Not sure if this is possible since it's all just comments, but would be cool if you could somehow mark this as an answer :D

avatar image hussainAbis Nov 27 '18 at 10:32 AM

Sure yeah I'll do that if you "convert this comment into an answer" from the drop down next to the reply.

avatar image ndelchen Nov 27 '18 at 10:33 AM

Ah, now I know! Thx :)

(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