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:
- Create two game objects: player and door.
- Add collision objects to the game objects and add adequate shapes to the collision objects.
- Make the collision objects triggers.
- Add a script to one of the objects.
- 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
- 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)))