I’m trying to predict where a pawn will be. So I’m trying to grab it’s movement component. If it’s got one, the AI should then lead the target.
if (FocusPawn != nullptr && FocusPawn->GetMovementComponent() != nullptr)
{
FVector velocity = FocusPawn->GetMovementComponent()->Velocity; //THIS CRASHES!
Problem is, it’s got a movement component with an uninitialized velocity, which is a crash. Normally, you’d fix this by initializing it, but that’s EPIC’s code, and they don’t initialize it. I know I can’t check if a variable is initialized at runtime (other than seeing if it crashes.) But is there some other way to tell?
Can I tell if the owning pawn has moved?
The other thing is, the pawn this is happening on doesn’t have a MovementComponent, at least not one I can see in the editor, so why is it passing the nullptr check?