How to get name of actor that is hit?

Hello forum,

Recently I’ve begun recreating Space Invaders in Unreal Engine for C++ practice. Currently I’m trying to implement a couple Ifs that will be executed in OnHit(): one that destroys the alien when it collides with a projectile, one that reverses the aliens’ direction when they hit a wall, and one that will end the game if an alien collides with the player.

My question is: How do I extract the name of what I’ve collided with from OnHit()? I know it must have to do with the OtherActor parameter, but I’m not sure how to build my If statements from that.

Any ideas that might help would be appreciated.


Does OnHit() return a FHitResult struct?

If yes, you can use .GetActor() or .GetComponent()

Googling “OnHit()”, I only find it as a blueprint, where you can drag a node off called “other actor”.

Privacy & Terms