What is Hit.Actor? (Not GetActor)

While doing the challenge, I came across “Actor” on the FHitResult documentation page.
I quote the docs:
“Actor hit by the trace.”

While, eventually I ended up using GetActor (which is also the solution used in the video).
Quote the docs:
“Utility to return the Actor that owns the Component that was hit.”

So what does Actor do as opposed to GetActor (which is what we did want in the challenge)? They just sound confusingly similar and hoping someone can clear it up for me.

Thanks!

1 Like

Actor is a public variable, GetActor() is a function.

The variable is wrapped in a TWeakObjectPtr which is used to explicitly not affect garbage collection

It can return nullptr later if the object is garbage collected. It has no impact on if the object is garbage collected or not. It can’t be directly used across a network.

Most often it is used when you explicitly do NOT want to prevent something from being garbage collected.

GetActor() just returns AActor*

3 Likes

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

Privacy & Terms