Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UI appear ontriggerstay? HELP

Discussion in 'Scripting' started by brodan100105, May 25, 2017.

  1. brodan100105

    brodan100105

    Joined:
    Jul 16, 2016
    Posts:
    13
    I am making a game. And I need a UI Image to appear at the top of the screen when I enter the collider that is following a object (enemy). So I need ontriggerenter/stay/exit right? Does anyone have any idea how to? If so, i would ideally like a code to use, but if you have a reference I can read or a video I can watch, anything would help, because as of now I am stuck and do not have any code. Thanks!
     
  2. Flynn_Prime

    Flynn_Prime

    Joined:
    Apr 26, 2017
    Posts:
    387
    Use a GameObject.GetComponent within your trigger to reference the UI image you want to appear and use GameObject.SetActive (true) somewhere within your if statement that delects collisions with enemies
     
  3. brodan100105

    brodan100105

    Joined:
    Jul 16, 2016
    Posts:
    13
    Do you think you could show me a script of some sort by any chance?
     
  4. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065