Game object made with factory.create() just doesn't show on screen

I’m trying to spawn a game object in the place where the player clicked. I’ve gathered that I can do that with factory.create(). I can confirm that line of code executes via some print statements, but the game object just doesn’t show. I modeled it after the Sidescroller tutorial.

I’ve looked around for settings or things I can adjust, but I can’t find anything that seems relevant. I suspect it’s something wrong with the sprite/atlas because the object doesn’t show even when I manually add it to main.collection and drag it right to the center of the screen. Doesn’t show in the editor either–just gives me a small 32x32 box.

I’ve noticed that the atlas has size 64x64, but my sprite is 32x32. Is that a potential factor? I can’t change the size on the atlas to find out.

What am I missing?

What z position does your object have relative to other things in the same location? If lower, it would be rendered underneath and thus not visible.

Good idea. I tried that by setting the z value on the vector3 to 255, but no difference. Still can’t see a thing.

pos = vmath.vector3(action.x, action.y, 255)
factory.create("/obj_factory#chip_factory", pos)

EDIT: To clarify, the z-values on all of my objects are left at default, so they should all be zero. I checked them all again just now to confirm that’s the case.

Note that if you are using a default render script then the visible range is -1 to 1.

1 Like

Silly suggestion, but have you added the sprite to the game object? You say you don’t see it in the editor, but you do see it in the game object right?

Ah, okay. I thought z values ranged from 0-255. I changed it to 1 and now it appears. Thanks!

1 Like

Great. Note that when sprites share a z value the results are unpredictable. One might show, or the other.

1 Like

You can change the range of z-values that will render in the render script:

Also note that the z-value is the aggregated z-value of the game object and component z-values and also including the z-value of any parent game object:

1 Like