I’m spawning a factory on initialization but when I call factory.create(url, position) I want to know about the prototype object’s sprite size to pass a calculated position. However, since the factory object is not yet created and added to table I can’t yet traverse using msg.url() and get the sprite size.
I’ve tried directly reaching out to the prototype object but since the prototype is a standalone object and doesn’t belong in a collection, go.get("#sprite", "size") can’t resolve the component.
Is there a way to accomplish what I’m trying to do other than typing out the sprite size manually?
The end goal would be to access the sprite size of the prototype object, use it to for some calculations and then pass a position to a factory.create() call. My issue is: if I create the factory first in order to have access to it, it also means that it’s spawned and visible already.
You can’t do that. You need to spawn it first. Do you need the sprite size for calculating a position to pass to factory.create? If this is the case then spawn it without passing a position and position after creation instead.
I tried leaving out the position argument but leaving out means it gets created at vmath.vector3(0, 0, 0).
For some silly reason, I thought that if I updated the position later on at update, there’d be a visible jump, the object moving from default to a calculated position. That’s why I ruled that out.
Now that I actually tried setting the position afterwards, like you suggested, it works like a charm. There’s no visible jump.
My bad for playing it in my head but not testing that option out. Thanks @britzl !
You can change the position immediately on the line after it has been created. As long as you set the position during the same frame as it was created there should be no visible jump from one position to another.