I have 2 GO, both the same, each time I launch the game, the sprites render order change randomly.
1º why ?
2º how can I control that?
I have 2 GO, both the same, each time I launch the game, the sprites render order change randomly.
1º why ?
2º how can I control that?
Might be a z-war. Are they on same z position? If so you have to define different z according to their order. (z: -1 ↔ 1 )
yes,the same z position. thanks
maybe a great feature , change the z position of the sprite, instead of cerate 1 GO for each sprite
You don’t need to create GO for every sprite. Simply you can add more than one sprite in a single GO and you can change their z position.
Like this:
Go-Z : 0.5
Zombie-Z: 0.4 ( Go z + Zombie z == 0.9)
Demon-Z: 0.5 ( Go z + Demon z == 1)
I dont understand how can you change z position, if the positio is in the gameobject
More test.
Gameobjects with diferent sprites positions. The GO with z position = 0 is above the GO with z position = 0.2 and 0.3
another thing, I try to modify the render script, but I cant save the file, why?
thanks
Sprite components also have a position property which is relative to their game object. So if your game object is at z = -0.01 and your sprite is at z = -0.001, then it’s final “absolute” position will be z = -0.011 (assuming there’s no scale involved). You can change Sprites’ positions in the editor but not at runtime.
Are you trying to modify the render script in the “builtins” folder? Everything in there is read-only. If you want to change it, make a copy of it outside that folder and change that (and don’t forget to change what file your game.project is using).
Need to change sprites z at runtime, then im using a collection with a factory, that creates GO with the sprite, and different Z positions, is the best way I think…
Good to know that info, thanks.
I’ve added some notes on component draw order in the overview manual for components.