0

I am slowly sorting out the engine and have run into one problem that I cannot solve.

How to make the condition of collision with an object and pressing a key (for example, to enter the door) work.

I do it in the object script:

function on_input(self, action_id, action)
    msg.post(".", "acquire_input_focus")
end

local function obj1(self, action_id, action)
    if action_id == hash("up") and action.pressed then
    -- print("obj1 and UP")
        msg.post("game:/loader", "new_level", {})
    end
end 

function on_message(self, message_id, message, sender)
    if message_id == hash("trigger_response") then
    -- print("obj1 ok")
        obj1(self, action_id, action)
    end
end

But it doesn't respond in any way to clicking up. What am I forgetting?

Progman
  • 16,827
  • 6
  • 33
  • 48
  • Looks like you acquire your input focus, in the input script. Therefore, you won't receive any input, since you haven't asked for focus yet. Try placing it in the `init` function and calling that too. – LarryTLlama Jun 12 '23 at 10:17

0 Answers0