Casting, how does it work in the code?

Can someone explain how casting works?
From what i understand this code:

ANode* node = Cast<ANode>(hit.Actor);

is trying to cast Actor that have been hit by cast to ANode and assigns null to node if it fails?

When you perform a Cast(Object) we use the unreal reflection system to ensure the object being cast is of the type specified in the template arguments . If it’s not, we return NULL.

Cheers,
Nick

Well the thing is that the code above doesn’t work :frowning:

i get error C2665 Cast: none of the 3 overloads could convert all the argument types

Maybe there is a problem with FHitResult? hit.Actor gets an actor hit by the trace right?

TWeakObjectPtr Actor;

It’s a weak object pointer, you’ll need to call Get on it to return the actual Actor (or null if it was garbage collected).

Is there some information about Casting speed execution if I use the Cast method? Is it bad approach to use Cast method in cycle functions like Tick ?