Download

Use F only in trigger

Hi im pretty new to this and seeing if anyone can help me with this more then likely relatively easy question. Im looking to only Use the F key when im inside my OnComponentBeginOverlap trigger. What i have now works like stated only in the trigger yes but at the same time when the Component Destroys and i press F any time after that im getting an error stating

“Error Blueprint Runtime Error: Attempted to access Cube via property Cube, but Cube is pending kill from function: ‘ExecuteUbergraph_Wood’ from node: DestroyComponent in graph: EventGraph in object: Wood with description: Attempted to access Cube via property Cube, but Cube is pending kill”

Any ideas how to fix this error im running into??

Wood.jpg

You’re asking the cube to be destroyed after you’ve already called for it to be destroyed. It’s unregistered so it can no longer accept instruction, hence that issue. After F Pressed, put in a IsValid node checking the Cube and if it is Valid then call destroy. This is “checking your pointers.” This way it won’t try to send instructions to a de-registered object.

No need to capture all input on the cube.

Instead, keep the handling of input on your character.

And enable disable it on your character.

e.g.
Create a bool on your character: “IsFEnabled?”
, default to false

When your character enters the volume, enable the bool
When he exits the volume disable the bool

Have the input event for F on your character check the state of the bool

Thank you guys so much i knew it would be an easy fix.