Hello.
To solidify my knowledge after following toontank course, I’ve tried to work on a personal project (industrial robot environment).
Basically, I need to pick up spare parts with my robot, and place them on a mechanical assembly in my scene.
I need to spawn those spare parts which are based on a class called SparePart, but with different static mesh according to the part.
I’ve tried the function used in toon tank course, and made this function :
void ASpawner::SpawnPart(int PartIndex)
{
FVector SpawnLocation = GetActorLocation();
FRotator SpawnRotation = GetActorRotation();
// if(PartList[PartIndex])
// {
if (SparePartClass)
{
UE_LOG(LogTemp, Warning, TEXT("Class pointer valid"));
ASparePart* TempSparePart = GetWorld()->SpawnActor<ASparePart>(SparePartClass, SpawnLocation, SpawnRotation);
}
UE_LOG(LogTemp, Warning, TEXT("Spawning working"));
// }
}
Eventually, I need to choose the part I spawn from a list, hence the commented PartList array.
My issue is, as soon as I enter the if statement, the window freezes. This is probably due to a null pointer, but I can’t figure out where the issue is, especially since my test is true…
In the .h file, I’ve declared :
TSubclassOf<ASparePart> SparePartClass;
Any idea ??
Thank you