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. 

Player spawns at wrong Player Start on Play

 APlayerStart* AEOTGGameMode::Choose_Player_Start_Func() {
     APlayerStart* returnValue = NULL;
     FString TutName = "Tutorial";
     FString MGName = "Main_Game";
     bool thisInstanceBool = Cast<UEOTGGameInstance>(GetGameInstance())->Tutorial_MainGame;
     for (TActorIterator<APlayerStart> Play_Start_Itr(GetWorld()); Play_Start_Itr; ++Play_Start_Itr) {
         if (Play_Start_Itr->ActorHasTag(FName(*TutName))) {
             if (thisInstanceBool) {
                 returnValue = *Play_Start_Itr;
                 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Tutorial Spawn"));
                 break;
             }
         }
         else if (Play_Start_Itr->ActorHasTag(FName(*MGName))) {
             if (!thisInstanceBool) {
                 returnValue = *Play_Start_Itr;
                 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Main_Game Spawn"));
                 break;
             }
         }
     }
     return returnValue;
 }

The above is my code that lies within the GameMode class in C++. GameInstance holds a persistent variable for choosing between which Player Start to choose. By default on creation, the value is true, so by the code above, the player SHOULD spawn at the Tutorial Player Start location on start of the game as shown below ![alt text][1]

[Tutorial Right Spawning Location]

but somehow, the player can still spawn at the 2nd of the 2 Player Starts, which is meant for player who wish to skip the tutorial. ![alt text][2]

The GameInstance variable, as stated, is set by default to true. The value changes within this menu widget which asks for yes or no if first time playing the game ![alt text][3]

however, the player still randomly spawns at one of the two player starts, on player start and through this widget. This is confusing me and I don't understand why.

Also, within that coded function for choosing player start, I have tried to flat out return NULL for the player start and it still randomly spawns at one of the two locations. The debug statements and the gameInstance variable value changes correctly, but the player start spawning is still randomized. Please, help is very much appreciated at this time.

Below for reference is how the player uses the logic to spawn. ![alt text][4]

*removed pictures

Product Version: UE 4.6
Tags:
more ▼

asked May 31 '15 at 10:49 PM in C++ Programming

avatar image

MajinKen
58 17 24 33

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

1 answer: sort voted first

IGNORE THIS QUESTION. PROBLEM HAS BEEN FIXED. See that Construction Script for the player? The connection from the function call to set actor location was incorrect. VERY INCORRECT. Should be connected to GetActorLocation.

more ▼

answered May 31 '15 at 10:58 PM

avatar image

MajinKen
58 17 24 33

avatar image NymKappa Jun 29 '16 at 06:44 AM

I think I ran into the same issue https://answers.unrealengine.com/questions/443123/character-location-is-wrong-using-setactorlocation.html . Could you elaborate about it ? What should be connected to GetActorLocation ? Thanks.

(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