Hello, I’m a beginner in Defold.
I’m having trouble passing a message to player.script. I can’t figure out what I’m missing.
trigger.script
function on_message(self, message_id, message, sender)
if message_id == TRIGGER_RESPONSE then
if message.other_group == PLAYER then
if message.enter then
msg.post("main:/player/player#player", "player_in")
print("in", message.other_id)
--self.is_player_near = true
else
msg.post("main:/player/player#player", "player_out")
print("out", message.other_id)
end
end
end
end
player.script
function on_message(self, message_id, message, sender)
if message_id == hash("player_in") then
print("get")
self.is_interactive = true
elseif message_id == hash("player_out") then
self.is_interactive = false
end
end
The trigger is working, the issue is somewhere in the player
This work fine
forge.script
function on_message(self, message_id, message, sender)
if message_id == hash("disable") then
go.set(".", "scale", vmath.vector3(0)) -- TEST
end
end
player.script
function interact(self)
print("interact")
msg.post("main:/forge/forge#forge", "disable")
end