UI "disable" and "enable" (SOLVED)

Hi everyone, please answer on my question.
I have a door and player. How I can enable UI-node when my player stay on door trigger and disable when my player don’t stay on trigger. (Sorry for my bad English)

Here’s one way:

  1. Create two game objects: player and door.
  2. Add collision objects to the game objects and add adequate shapes to the collision objects.
  3. Make the collision objects triggers.
  4. Add a script to one of the objects.
  5. In the script’s on_message() function, add something like this:
function on_message(self, message_id, message, sender)
  if message_id == hash("trigger_response") then
    if message.enter then
      msg.post("#guicomponent", "enable_the_node")
    else
      msg.post("#guicomponent", "disable_the_node")
  end
end
  1. Add/modify the gui script on the gui scene with the node to respond to the message:
function on_message(self, message_id, message, sender)
  if message_id == hash("enable_the_node") then
    local n = gui.get_node("the_node")
    gui.set_enabled(n, true)
  elseif message_id == hash("disable_the_node") then
    local n = gui.get_node("the_node")
    gui.set_enabled(n, false)
  end
end
10 Likes

thanks)))