Hello friends, I want to ask for your advice on an issue. Actually, calling it an issue might be wrong; it’s more about my lack of knowledge.
Anyway, here’s my situation: In my project, I have a BP_Trigger that gets activated when I enter it, and a BP_Light blueprint. I used Event Dispatcher to connect them.
Currently, if I activate the On Component Begin Overlap inside BP_Trigger, the On Toggle event gets triggered, and it activates the system inside BP_Light.
However, I want it to work differently. When my character enters the trigger, the light should not turn on immediately. Instead, I want it to activate only if I press “F” while inside the trigger.
Imagine that you already have a reference in your character for the light you are going to call “Start” on. (actually go ahead and hardcode it) Make the mechanic so hitting “F” will activate it.
Once that works your only need to pass a reference of the light once you enter the trigger area (and remove it on exiting)
At this point you will have a working mechanic and I would go around and fix it up a bit it by moving the collider on the player instead of the trigger. (instead of the trigger checking if the player is inside, the player to check if a trigger is inside interaction range)
Hope this gives you enough direction to do it on your own
Hello! So, by experimenting on my own and taking your suggestions into account, I created this system. Of course, I’m not sure if it’s clean and stable, but do you think the approach I followed is correct?
My goal was to make the system work only when my character enters the trigger and I press F. I managed to do it this way.
Seems like you tried to make a combination of both of the suggestions provided in this topic of yours, plus the one from the distinguished gentleman above.
I wanna start by explaining my suggestion. I didn’t use event dispatchers or interfaces to achieve your objective in order to keep things nice and simple. I just used custom events which I access by casting. It could be improved, however the approach you’re trying to go for above kinda defeats the purpose of optimization, due to unnecessary casting, receiving inputs from your “trigger” actor, and obsolete use of event dispatchers.
Now the other distinguished gentleman in your other topic I linked at the beginning suggested the use of interfaces, and did an amazing job explaining it The only missing part was that you do need to cast to the blueprint that you wanna connect “wirelessly” at some point.
So, if you want a better approach than my initial suggestion, you can implement this setup: