Hi everyone! My name is Antonio and I’m new to BP so this might be a noob question but I couldn’t find the answer by myself. And i apologize if the question was done already but I couldn’t find it.
I’m trying to make an interacting object, a fireplace, that can be activated by pressing a button but only when looking at it. I’ve managed to make it work so you can only activate it by pressinf “F” when the Player Controller is near the object with this script:
Now I want that when a Box Trigger called “Vista” in my ThirdPersonBP collides with the Box trigger in the fireplace_BP it enables the input to turn the fire on or off like it was the PlyerController in the script above. How can i do that?
Thanks for your time and have a nice day!
PS: Sorry for the bad grammar, I’m not a native English speaker.
Simplest way is to run a Line Trace every tick, from the player pawn forward as many units as you want to reach.
Traces return the object they hit and you can test that object for whether it implements a certain interface.
You can create a blueprint interface called Interactable for iinstance, and set the fireplace BP class defaults to Implememt that interface. The interface can have a function callec Interact.
That makes it so any BP with that interface also has that function
So then you just make it so when the line trace hits something it stores that object in a variable on the playercontroller or the pawn. Then when the F key is pressed you check whether the stored object is both valid and implements interface Interactable (there are nodes for both), and if it does you call the function you made for that interface.
On the fireplace BP the function lets call it Interact, can toggle the fireplace on and off.
Since the trace has a limited distance you dont need an overlap event handler anymore