1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  3. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
    Dismiss Notice
  4. Unity 5.5 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  6. Unity 5.6 beta is now available for download.
    Dismiss Notice
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
    Dismiss Notice
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
    Dismiss Notice

Power button

Discussion in 'Scripting' started by ksam2, Apr 28, 2012.

  1. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Messages:
    831
    hi again again and again. I'm just getting crazy :mad: I am new in unity please help me

    I have a Power button in my game and I want when I getting close to button and press E one animation get play
    but I have no Idea how can I do that, I've search for that but can't find anything

    my mean is something like trigger in UDK
     
  2. RANDOM++

    RANDOM++

    Joined:
    Mar 10, 2012
    Messages:
    68
    There are trigger functions in Unity so do a search on (OnTriggerEnter or OnTriggerExit) and I'm sure things will get a bit more clear.
     
  3. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Messages:
    831
    thanks. I've seen that but I don't know how it works
     
  4. RANDOM++

    RANDOM++

    Joined:
    Mar 10, 2012
    Messages:
    68
    If you have a game object with a meshcollider attached to it, you can set a property 'is trigger' to true inside the inspector.

    Inside your script you can then check with the OnTriggerEnter function if some 'other' collider has enterered the trigger, and if so, perform any desired action.

    If you like to know more, either read some more about it or wait till someone else comes in and can give you more details on this because I'm a starter with Unity myself :) However, the function itself is pretty easy to understand.

    Oh btw, the 'other' collider is if I'm correct a special case, so you don't have to assign a specific collider in the script in order for the trigger to work, it will get triggered by any other collider that collides with it.
     
    Last edited: Apr 28, 2012
  5. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Messages:
    831
    OMG. that was a big help thanks a lot a real lot :D thanks thanks
     
  6. RANDOM++

    RANDOM++

    Joined:
    Mar 10, 2012
    Messages:
    68
    Good luck with it and if you have any problems just post it here, I always like to know what went wrong/good and if I can help I will :)