Unable to destroy specific actor

Hello! I’m trying to create a simple pickup item system and I’m stuck on destroying the actor when pressing the “E” key. The code works without the == but destroys all actors, but then when I add the == it does not recognise the actor in the world. How can I get it to recognise the actor?

Hi @Sphynxalot ,
If you want to check if the Hit Item is a BP_X or not, its better to use Cast rather than == check. Here is an example:

please reply if its not the case

2 Likes

iamagoodspoon1 is right
that blue pin mean that is stored an actor
so you are checking if that actor you raycast, is exactly the actor you placed in that var.

you may use cast to ,
or search for “get class” and check if the class of the raytraced actor
is the class you need.

Hi, yes this worked! I knew it would be something simple like that :smiley:
Would this also work if I casted it to a parent blueprint? Would it target only the parent and child blueprints?
Thanks a lot!

Hello @Sphynxalot ,

Yes, If you cast it to the parent blueprint, all of the child class will be detected too. for example
image
if you cast for Fruit, apple and orange will be detected too. But if you cast for Orange, only orange will be detected (Apple n fruit won’t be)

1 Like