I have two game objects with different urls with the same script , In the init I get the spawn pos that is correct on the console log , but appear to get the position off the other gameobject . I want to save the init
position independent of the game object with the same script.
It sounds like you tried to use it outside of a function. âselfâ isnât a global, it is an argument passed in to the functions called by the engine. You just need to do:
function init(self)
self.initPos = go.get_position()
end
Then you can access it from inside the other basic function (update, on_message, etc.)
local function show(self, other_args) --notice self is an argument
--do something with self
end
function init(self)
show(self, other_args) --self passed as an argument
end