Hey -
This was tested inside of a FirstPerson Template project. Using following code inside OnFire() function I was able to successfully “see” newMesh component when I pressed LMB in game:
TArray<AActor*> TestCubeActorArray;
UGameplayStatics::GetAllActorsOfClass(this->GetWorld(), AMyActor::StaticClass(), TestCubeActorArray);
if (TestCubeActorArray.Num() > 0)
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Black, TEXT("We got something!"));
}
}
else
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::, TEXT("We failed to get anything."));
}
}
AMyActor* TheActor = Cast<AMyActor>(TestCubeActorArray[0]);
if (TheActor->newMesh)
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Cyan, TEXT("I can see Actor's newMesh"));
}
}
else
{
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("Actor mesh? What actor mesh?"));
}
}
What this code does is get all actors of type MyActor and adds them to an actor array). After creating array it takes all of actors in array (there’s only one that I’ve added to level) and casts first array element to AMyActor class. It then checks if it can see newMesh of that actor and prints out a message accordingly. Let me know if this helps at all or if you’re still having trouble accessing actor components from another class.
Cheers