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 ‘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:
- OtherCharacters[i] is what you expect (i.e. is a valid character),
- what OtherCharacters[i]->GetActorLocation() returns
- 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.
- Wasn’t Sure