I am attempting to create an object with a supplied position. I have a script that creates an object via a factory and does not take the position I expect:
local pos = vmath.vector3(400, 400, 1)
print("creating enemy at " .. pos)
local newId = factory.create("/EnemyFactory#factory", pos)
When it creates the object, it creates it at effectively (0,0,0).
That is surprising. I can’t see anything wrong. What if you do go.set_position(pos, newId) on the line after factory.create()? What if you print(go.get_position(newId))?
local pos = vmath.vector3(s.xPos, s.yPos, 1)
print("creating enemy at " .. pos)
local newId = factory.create("/EnemyFactory#factory", pos)
-- new debug lines
go.set_position(pos, newId)
print(go.get_position(newId))
and the results I get are the box at the same position
I think I have fixed my issue. I realize while posting my previous post, I was using a GUI with a box in it to represent the enemy and I would probably be better off using a sprite
so I made an image and rigged a sprite to the Game Object I was using instead of a Gui, and now everything is working as intended. Im not sure about the interaction of go.set_position() with an object with a gui for a child but I think I have solved my problem.
thanks
Also for some reason all my other posts have been flagged as spam and hidden?
GUIs are (by default) rendered in a separate pass in screen space so the position of the game object you put the GUI component in does not matter at all.