I am trying to track the Z location of my ball actor while in the scope of my paddle actor. I think it has to do something with the way I get the reference to my BallActor or the location methods/fields I am referencing must not be correct. In my editor the BallActor is set with it’s Z location to 1500.0f. So why does GetActorLocation().Z for my BallActor return 0.0?
void MyPaddle::BeginPlay()
{
Super::BeginPlay();
for (TActorIterator<AActor> ActorItr(GetWorld()); ActorItr; ++ActorItr) {
if(ActorItr->GetActorClass() != NULL) {
if (ActorItr->GetActorClass()->GetName().Equals("AOtherActor")){
BallActor = ActorItr->GetClass()->GetDefaultObject<AOtherActor>();
}
}
}
}
// Called every frame
void MyPaddle::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
if (GetActorLocation().Z < BallActor->GetActorLocation().Z ) {
... code ...
}
}