Search Unity

How to make unlocking door with code?

Discussion in 'Scripting' started by Dolke, Jun 16, 2018.

  1. Dolke

    Dolke

    Joined:
    Dec 16, 2016
    Posts:
    39
    Hello.

    Im thinking about how to make door unlock when i enter the code?

    I need when I come close to the door,some kind of input pops up ( or it pops up when I click E or something on keyboard),and when I enter the code door unlocks or opens if the code is correct.

    I do not know how to make this.

    Can someone just describe me how to do this and I will try on my own.
     
  2. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Unfortunately, this is too vague a request. There are many ways of doing this, both architecturally and aesthetically. :)

    If you want proximity to a location, consider looking into trigger colliders. If you want to respond to a keypress, look into Unity input methods. If you want to accept a code, look into Unity UI components.

    Just for communication between components alone, there are a number of ways of doing this, including things like GetComponent<type> and serialized objet references set in the Editor.

    If none of the above means much to you, could I strongly suggest you scroll to the very top of this page and click on the "Learn" link. You won't regret it. :)