function init(self)
msg.post("ground/controller#script", "set_speed", { speed = self.speed })
end
function on_message(self, message_id, message, sender)
if message_id == hash("stop") then
msg.post("ground/controller#script", "set_speed", { speed = message.speed })
end
end
It is my controller script. When my hero eats the obkect with the script below< my ground should stop(it’s speed has to be 0), but it is not working
self.speed = - 300
end
function update(self, dt)
local pos = go.get_position()
pos.x = pos.x + self.speed * dt
go.set_position(pos)
if pos.x == -32 then
go.delete()
end
end
function on_message(self, message_id, message, sender)
if message_id == hash("contact_point_response") then
if message.group == hash('hero') then
msg.post("level/controller#script", "stop")
go.delete()
end
end
end