Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Light Switch Function

Discussion in 'Scripting' started by Else1996, Jun 6, 2015.

  1. Else1996

    Else1996

    Joined:
    May 31, 2015
    Posts:
    6
    Dear Community,

    And although I have a problem, I need a script where with when I am faced with a cube, which he then to say the bottom of the screen "Press the E button to enable or disable to" And if I should then press the E key all the lights Unignore itself?

    Has irgendswer an idea?

    Sincerely
    Daniel Elskamp
     
  2. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987
    You can maybe have a collider on the switch, do a raycast through the players crosshair at all time, check to see if it hit the lightswitch, maybe do something clever with delegates and events so that if your raycast hits an object marked as "Action E" it will check for the light switch event, grab the lights message and display it through ui and if e is pressed it will activate the event to which all the lights subscribed to the event will turn off.
     
  3. Else1996

    Else1996

    Joined:
    May 31, 2015
    Posts:
    6
    Thank you for your answer.

    But I was actually looking for a code. What I can then make the player who is on the light switch, and then press the button to then go out and approach the light.