Instance (null) not found | Why?

#1

I have Tile Map name “item” and I want to check.
First I do this.

function on_input(self, action_id, action)
	if action_id == hash("space") then
		local item = go.get_id("item")
		print(item)
	end
end

DEBUG:SCRIPT: hash: [10046918326113036017 (unknown)]

Now, I try to change the position.

function on_input(self, action_id, action)
	if action_id == hash("space") then
		local item = go.get_id("item")
		print(item)
		go.set_position(vmath.vector3(0,123,0),item)
	end
end

DEBUG:SCRIPT: hash: [10046918326113036017 (unknown)]
ERROR:SCRIPT: /main/Test.script:30: Instance (null) not found
stack traceback:
[C]: in function ‘set_position’
/main/Test.script:30: in function </main/Test.script:24>

0 Likes

#2

Do like this, no need to get the id first:

go.set_position(vmath.vector3(0,123,0), "item")
1 Like

#3

Make sure you’re not confusing components and game objects. A tilemap is a component.

  • Component names in URLs will start with a “#”, like this: “object#tilemap”.
  • You can’t use go.get_id() on a component, only the game object that it is on.
  • You can use go.get_position() and go.set_position() with a component URL, they will completely ignore the component part of the URL and act on the game object.
1 Like

#4

mmm

0 Likes

#5

ERROR:SCRIPT: /main/Test.script:29: Instance item not found
stack traceback:
[C]: in function ‘set_position’
/main/Test.script:29: in function </main/Test.script:24>

I got this error instead.

??

0 Likes

#6

@jeung.nattanan Please read Ross answer:

And please read the Addressing manual to understand how reference game objects and components in the engine:

And if you’re still not able to get it to work then please follow these instructions to get help:

0 Likes