[SOLVED] LineTraceSingleByObjectType()

Cool lecture! I finished it with no problems but I’m confused as to why this works. If the tick component is called every frame, then shouldn’t the OUT parameter Hit be null for most frames? If Hit is null then how are we able to call Hit.GetActor()?

I feel like we should have to put GetWorld()->LineTraceSingleByObjectType inside of a conditional if statement and only call Hit.GetActor if that if statement is true.

My code is working properly but I feel like this is exposing a weakness in my logic.

Sorry I missed this but FHitResult is a struct which holds several values, it can’t be null.
Hit.GetActor() is going to return the actor the struct holds a pointer to or nullptr.

1 Like

No problem! Thanks for getting back to me. I’m glad the solution was so simple.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms