Hello to you all!
I have a task to make a table lamp that only lights up when player looks at it. I’m using Point Light for it, not emissive colour, but I just can’t find how to make light work only when player looks at it.
Does anyone have any idea (preferably working)?
Hello to you all!
You could have some sort of invisible longish cube in front of character set for query. If the component overlap, check if the point light is the component then turn it on.
the point light with a overlapping sphere that will trigger when character is within the sphere. It will need to check if the player is looking at it based on (object location - player location)<DOT>(player forward vector) >0.8 then turn on the lights.
Depends what you mean by look at it -
If you want a subset of the view frustum, eg anytime it is around the center of the screen, then use a spherecast from the center of the screen in the forward vector of the camera.
If you want it to render any time it is in the view frustum, then possibly:
Convert World Location to Screen Location will return a boolean if it is in the player controller’s viewport or not.
I think you can try to project light world location to screen and toggle it by success/fail of that function. (from player controller)
here is usage example - https://forums.unrealengine.com/showthread.php?50130-UMG-Tutorial-Placing-Widgets-Over-Actors-In-Screenspace
remember that it requires Tick, so may be expensive in some cases.
Think this would work for you: http://www.tomlooman.com/tutorial-multiplayer-supported-usableactor-system-in-blueprint/
Use his system of getting ‘focus’ and unfocus on items in the world. Once you ‘focus’ on something (lamp) you can then do anything you want after that, including turning it on or off. Currently he has it highlighting the object - you can just change that to trigger a different behavior.