I didn’t really understand how this works. ActorHit is type AActor and as long as I know to check a value like if(some_value) some_value should be in type boolean. So how does this if(AActor) actually work?
In C++ true means anything but 0, and false means 0
ActorHit
is a pointer if i remember correctly. So after you do something like
ActorHit = checkIfActorWasHit()
// This function will return either 0
(or nullptr
, which will also be interpreted as 0
), or actually pointer to some actor that was hit (Something like 0x02A34
), which is not 0
.
So now your if statement will understand whether there is something was hit or no.
It is a shortcut for:
if(ActorHit != 0)
or
if(ActorHit != nullptr)
Thank you for your answer. Also, does if( !Something) means if( something == false || something == null) or if (something == false) ?
In other words does !Something means Something is not true, or something is false?
if(!Something)
means Something == false
or you could also see it as Something != true
Those would be equivalent
Now it will depend on Something type to convert to bool for the if statement to be evalueated
Got it! Thank you very much
Glad to help. Good luck!