camera.script 529 B

12345678910111213
  1. function on_message(self, message_id, message, sender)
  2. if message_id == hash("follow") then -- <1>
  3. go.set_parent(".", sender) -- <2>
  4. elseif message_id == hash("unfollow") then -- <3>
  5. go.set_parent("camera", nil, true)
  6. end
  7. end
  8. --[[
  9. 1. Start following the game object that sent the `follow` message.
  10. 2. This is done by parenting the camera component to the game object that sent the message.
  11. 3. Stop following any game object. This is done removing the parent game object while maintaining the current world transform.
  12. --]]