Search Unity

Automatic Door w/ Pass Code Key Pad.

Discussion in 'Scripting' started by PeppyZee, Apr 1, 2015.

  1. PeppyZee

    PeppyZee

    Joined:
    Apr 1, 2015
    Posts:
    20
    Hay All

    I am new to Unity and firstly I would like to say I am loving the learning curve, I am really enjoying the abundance of information available regarding it and its uses as well.

    So as new member I would like to post my first script, I hope to have responses that will better the script, hopefully stream lining it a lot so on that note I welcome your constructive feedback.

    I have included a Example file and the script here. Please feel free to use it in any way you see fit, happy to contribute if that is what I am actually doing :).

    NOTE: You will notice that all of the Projects Assets are Compressed, You will need to decompress the assets before running the example scene. However I have included the Script separately for quicker review.

    The Script is C# as I prefer this language above others.

    The Script allows the player to

    A: Unlock a door using a Key-pass Code;
    B: Lock a door using a Key-Lock Code;
    C: Has Optional Timer;
    D: Has Optional Skin;
    E: Has Sounds for Success, Fail, Lock and Unlock;

    Example has
    A: Functional Door
    B: GUI Keypad
    C: Sounds.




    Thanks for any input you can provide.
     

    Attached Files:

    Last edited: Apr 1, 2015
  2. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    Hello! Welcome to the Unity community. It can be a slow response on the forums sometimes, but there is an abundance of information.

    It seems you are on the right track with the efficiency of your coding (though I've only got a couple years experience), I don't have any major suggestions there, though I only took a quick look. What I would suggest is learning the new UI implemented in 4.6, as it appears you're using the Legacy GUI sytem? Here is a couple of great links to help understand that if I'm not mistaken:

    http://unity3d.com/learn/tutorials/modules/beginner/ui
    http://docs.unity3d.com/Manual/UISystem.html
     
  3. PeppyZee

    PeppyZee

    Joined:
    Apr 1, 2015
    Posts:
    20
    Thank you.. I will spend most of the day there now! lol thanks!

    I will also be sure to update this threat and script if I manage to implement any of the NEW UI. I would surmise and my quick review that this type UI would allow me to attached to an Item where the UI would remain attached to the object and not the camera, I am sure there are ways of achieving this with the Legacy GUI, but I have not investigated that as of yet,

    This was basically my first Use of "Animations", "Triggers", "Scripts" and 3D modeling, however I am familiar with the modeling aspect as I enjoy using 3D Studio max, Solid Works, Maya, and many others.

    I figure it is time to play with some of my creations rather then spend endless hours creating them and doing nothing with them.

    This is just but the beginning of a long journey of realizing a idea in the form of an interactive fantasy.

    Cheers for the rather quick response.
     
  4. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    No problem.

    Yes, that's about how it works. Start by setting up a Canvas, do some experimenting with how they work for yourself. You'll basically set up a canvas with "world space" and position it in front of your keypad. You can easily set up the logic from there. Make sure to note that your code will be adding Listeners or instructions to buttons that will have their own update functions, so the code you create will not be looping the draw.