Announcement

Collapse
No announcement yet.

Light turn on when player looks at it

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Light turn on when player looks at it

    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)?

    #2
    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.

    alternatively

    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.

    Comment


      #3
      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.
      -or possibly-
      GetLastRenderTime()


      see https://www.reddit.com/r/unrealengin...mera_frustrum/
      https://www.casualdistractiongames.com

      Comment


        #4
        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/show...In-Screenspace

        remember that it requires Tick, so may be expensive in some cases.
        Rocketeer

        my portfolio
        my youtube

        Camera Volumes System
        Instanced Plugin
        Simple Portals
        Water Flow For UDK
        Setup Swarm

        Comment


          #5
          Think this would work for you: http://www.tomlooman.com/tutorial-mu...-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.
          Now available on the UE Marketplace: Inventory Examine Interface -- and -- Fifty Knobs and Dials -- and -- Thirty Buttons Pack -- and --Kitchen and Bath Handles for Arch Vis -- and -- Chat Bot A.I. Simulator

          Comment

          Working...
          X