Trouble Triggering Light by Distance

So, I watched the tutorial videos on Introduction To Blueprints on their Youtube Channel:

I decided to remake the Wall Sconch light used in this example, only I wanted to determine whether I was within range to flip the switch on the wall light based on distance between the player target & the instance of the wall lamp itself, instead of overlapping a trigger volume. However, it doesn’t seem to be working.

In my Nodes, I used the ‘Get Distance To’ Node, with one target being ‘self’ and the other being the Player Character, to return the distance float. I then created another float variable called Trigger Distance to be the distance by which I wanted the player to be within in order to trigger the light. Then I passed the bool value into a ‘Toggle Visibility’ Node, with both the Spot & Point lights as the targets, and an ‘F’ key event as the execution node for the toggle.

In-game, all this is resulting in is me being able to press the ‘f’ key anywhere to toggle the light on & off. Mind you, I have the Trigger Distance set to 5.0 at the moment. So i’m not sure where I went wrong. Here is a snap shot of my blueprint

Any ideas what I might’ve done wrong?

You have a Greater than symbol (>) when I’m assuming you probably want a Less than (<).

You’d probably also want to place a branch between your comparison and your show/hide node, that plugs into your < node. Connect the true to the show/hide, and leave the false unhooked. That way, when you press F, it’ll check the distance, and if you’re less than 5.0 units away from the object, it’ll allow you to switch it.

However, 5 units is very small (about 5cm, in real world terms), so you may also want to increase that :slight_smile:

Hi Sneakers,

The Get Distance to node is not plugged into your f key, so it is technically not doing anything. What you want to do is plug the Get Distance to node into your F key function before toggling visibility. This will execute the Get Distance to and then check to see if you are close enough.