C++ HUD Project Returns 0 Vector

I can’t understand why this line of code

FVector ScreenLoc = Cast<AShooterHUD>(MyPC->MyHUD)->Project(OtherCharacters[i]->GetActorLocation());
UE_LOG(LogTemp, Warning, TEXT("World To Screen Location is %s"), *ScreenLoc.ToString());

Returns a vector of 0,0,0

I’m on my phone so I am going to take some guesses since I cannot verify.

What’s OtherCharacters?
What’s ‘i’ (in OtherCharacters[i])? Is it pointing to a valid character?

Now this is just a guess, but I’d wager that if the cast fails, FVector is initialized using FVectors() empty constructor (init’s to 0,0,0).

Either way, troubleshoot it by verifying:

  1. OtherCharacters[i] is what you expect (i.e. is a valid character),
  2. what OtherCharacters[i]->GetActorLocation() returns
  3. Do you need to cast your hud for this line?

I think its not working because I didn’t do it in DrawHUD. But it’s ok since I think what I’m trying to achieve isn’t going to work.

  1. Valid
  2. Valid
  3. Wasn’t Sure