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"

Spawn character at different location

Hello everyone,

I am trying to get my AI to spawn at a different position each time one is spawned but I am getting a error when spawning the character. My error is error C3867: 'AActor::GetTransform': non-standard syntax; use '&' to create a pointer to member and this is my code


 void AAuroraSurvivalGamemode::OnSpawnWave(TSubclassOf<AAuroraBaseAICharacter> enemyClassToSpawn, int32 enemiesToSpawn)
     // Creating Spawn Params
     FActorSpawnParameters spawnParams;
     spawnParams.Instigator = Instigator;
     spawnParams.Owner = this;
     // For loop for spawning enemies
     for (int32 i = 1; i <= enemiesToSpawn; i++)
         // Generate random number for spawn switching
         int32 randomNum = FMath::RandRange(0, spawnLocations.Num());
         // Recast the array to the correct object
         TArray<AAuroraAISpawnPoint*>& CastedArray = reinterpret_cast<TArray<AAuroraAISpawnPoint*>&>(spawnLocations);
         AAuroraBaseAICharacter* AiCharacter = GetWorld()->SpawnActor<AAuroraBaseAICharacter>(enemyClassToSpawn, CastedArray[randomNum]->GetTransform, spawnParams);
         // Increment enemies alive
     // Increase the current wave count
     // Debug message on new round
     GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Green, TEXT("Current Wave: ") + FString::SanitizeFloat(currentWave));

My error is on the spawn character line. I am completely out of ideas on how to fix this


Product Version: UE 4.10
more ▼

asked Jan 11 '16 at 03:46 AM in C++ Programming

avatar image

1 3 6 8

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

1 answer: sort voted first

Have you tried "GetTransform()" instead of "GetTransform" ?

more ▼

answered Jan 11 '16 at 05:23 AM

avatar image

2.6k 95 41 111

avatar image Kevin.Soares7 Jan 11 '16 at 05:50 AM

It complies now but when I run my game it crashes right away

avatar image staticvoidlol Jan 11 '16 at 06:25 AM

It would help if you could share why it is crashing.

At a glance the only things I can see are:

  • GetWorld() might be returning null

  • randomNum might be larger than length of casted array (arrays are zero indexed)

avatar image Kevin.Soares7 Jan 11 '16 at 09:09 PM

It triggers a break right now I think it could be related to getting the spawn points using UGameplayStatistics::GetAllActorsOfClass

(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