Why am I getting error in here?

I use drop function with interface named “DroppableInterface” and when I want to drop my item it doesn’t work. When I close the game, editor gives me error “Blueprint Runtime Error: “Attempted to access Flashlight_C_2 via property K2Node_DynamicCast_AsDroppable_Interfacem but Flashlight_C_2 is not valid (pending kill or garbage)””. Why? I use “Held Item” variable (Actor object reference) to save the name of picked up item (When I interact with Flashlight actor the Held Item variable sets to Flashlight name but in error I see Flashlight_C_2)



1 Like

It looks like you intractable item set itself in the player, and then promptly destroys itself

The _C2 is just the name of the instance, it will probably never be the same as the name of your blueprint.

1 Like

How can I fix this? I need to destroy Flashlight in game

Sorry, I don’t really get your code. Here

You’re spawning a flashlight, and then hiding another one in the character.

And here

You’re destroying the actor that’s running the Interact code, whichever actor that is.

2 Likes

Ah yes, I got it and I solved it. I’ve just set the “Held Item” variable to "P_Flashlight" and to “P_Flashlight” I connected “DroppableInterface” so now it works. Thanks!

1 Like

Excellent :slight_smile:

1 Like