I’de like to know the difference between these two solutions for referencing a particular actor class. If I am able to return a reference to an actor with a collision volume, is it more efficient to check if it is equal to the desired class or to cast to the desired class? Are there differences between the references? Any information on what is happening in the back-end would be great as well.
The main difference is that cast checks inheritance too, for example if you cast a child class to a parent class it returns true and you can directly call all the functions of the parent class and access its variables.
The equal only works for the same class, and doesn’t allow you to do anything mentioned above, it could be more efficient than the cast (not sure about this) but certainly it doesn’t do the same thing
If you only have to check if it is a correct actor, I just use actor tags in my blueprints and check if ActorHasTag. If you need to access functionality, use Cast.
I literally never used GetClass and compared it to anything.
@AntiGravity this is really helpful, thank you. I was originally thinking of using an interface to check, but simply don’t need one for this use case. I also wasn’t aware of how tags are checked.