Problem with label in a gameobject

I think this is a bug, when I add a label to my gameobject, when I instantiate the text is not show, also is set to 1 z position and the card to 0, also if I change the scale of the gameobject de label text is hidden!

zfighting probably, make sure your label is closer to your camera than the sprite that should be further away. Remember you can parent multiple GOs together and create them with a collection to help with organization and easy relative referencing.

I dont use any camera (use the default render), the best option is create a collection a sort the different elements?

By camera I just mean how your scene is rendered with your renderscript, how the player’s screen sees your world. The default rendering is orthographic with -1 to 1 render range.

Using collections and then spawning them with factories is a very good method to dealing with assets like in card games. If you have not used them before give it a try learning.

You should be able to adjust the z position of the label without extra GOs in a collection though.

2019-04-18%2015_49_05-PureRef

1 Like

I try the collection and not work for me, also I prefer the gameobject, becuase only need 3 text more and is finish, the important problem is when I instantiate, not show the text and when I dropped is show (drop only change the position not anything more), also I change the z position, the sprite of the card and the label is 0.2 (I play with different values), I can change in run time the z position of de label? may be something wrong when is instantiate

You can only reasonably change z of label at runtime if you use the collection method. Because then you change z of a GO that is parent to the label. Using a bunch of GOs for organization at this scale is not a problem. Trust me getting collection factory method working well is a good idea, I have made card games and it is something you will probably have to transition to as your game gets more complicated.

1 Like

Okay, but the problem is the same, when I put something more than 0 on z position is gone off the screen, I try with the same thing with the gameobject that contains sprite (put 0.1 or 0.2)in the collection and not show. Strange no?

z positions are accumulative so you might be putting it outside of the default -1 to 1 render range. You’ll need to use a custom render script if that’s the case.

If you think there is a bug upload a minimal example.

Never mind, if I put in 0 position works, but on the preview of the gameobject not show, the same in the collection, can pass to me any link to a custom render with some layers or something like that? becuase this is a little strange… but works!!

The z positions of everything may still be bad, but I can’t tell based on that picture.

You can copy the render script from the builtins folder and modify that.

There are also rendercam and orthographic although for your game rendercam is what you want.

You’re off to a good start so keep learning and posting whenever you have questions. :slight_smile:

2 Likes

As @Pkeod said, z values are accumulative, so check every z value in your hierarchy up to a label (for example if you have your main collection, below is a go (game card) and below is a label, check if any of those have z value 1 (then adding label even 0.0001 above them will cause to reach out if the builtin in range) or a sum of them is above 1. The range of z in builtin render script (-1 to 1) should be sufficient, because you can use even 0.01 to differentiate layers. So take care about z values and everything should be OK :wink:

2 Likes

If you want to change the z-range a message is enough: https://www.defold.com/manuals/render/#_default_view_projection

2 Likes

Like always the support in this forum is incredible, many thanks for all your responses!!

5 Likes