You could do this by setting a boolean to true/false when colliding with the object and then using that boolean to determine if the F key binding should run its logic or not. The only problem with this method is setting the boolean back it its original value when the collision ends.
I would suggest making a trigger box or any type of trigger volume that is slightly larger than the box as one of its children. With this, you can use OnComponentBeginOverlap and OnComponentEndOverlap instead to set and reset the boolean when these events are triggered.
Hi
Do you have a specific BP for this actor? If yes, go inside it and add a “BoxTrigger”, use the OnComponentBeginOverlap as said by in the Actor Event Graph and cast to your player, the rest is like said.
Good luck
The thing you need is a Box Collision component, not a variable. Click the “Add Component” button at the top left, type in “Box” and it should come up. After doing that, make sure you have the component selected in the component list and then right-click in the graph. You should be able to add the OnComponentBeginOverlap and OnComponentEndOverlap events from the context menu that appears.
If you have problems getting these events to trigger, ensure that “Generate Overlap Events” is checked in the details panel for both the Box Collision component and the other actors that will be overlapping it.
I’ve added a custom event called DestroyBox=Press E.
I’ve tried to use the DestroyBox in DynamicBox but doesn’t work.
There is another blueprint class that generate boxes in an small volume,but I think that is not the problem.
With this set up, is that F event in DynamicBox ever actually being fired? By default, the DynamicBox isn’t what you’re possessing so it shouldn’t be receiving the input. This should work instead.
First, create two variables on your ThirdPersonCharacter. The first is a boolean to track if the player is overlapping. The second is a reference to a DynamicBox actor (MyBox in my example)
After that, set up the following nodes in DynamicBox.
This first checks to see if the ThirdPersonCharacter is overlapping the box. It then destroys the box using the reference and then clears that reference (since OnComponentEndOverlap never gets called since the actor has been destroyed). If it fails, it simply prints “Not Overlapping Anything”.