The label component blink when rotation GO over Y axes (SOLVED)

Hi,
I’m trying to make the card flip effect with perspective camera view and took strange behaviour of labels component.
Game Object has the back sprite and several labels with card parameters.
The some labels are blinking when GO is rotating. I quess they go behind to the sprite. But the other labels are not blinking.

Code of rotate animation:
go.set("hero","euler.y",-45) go.animate("hero","euler.y",go.PLAYBACK_LOOP_PINGPONG,45,go.EASING_LINEAR,5)

How it looks:

Perhaps what labels with some z-order are cutting by camera. But it’s so strange what label “def” works correct and not blinked with the same Z as other labels.

Any ideas?

2 Likes

Hmm, interesting. @Mathias_Westerdahl, do you know?

PS Love the card graphics!

1 Like

Huh, that seems a bit weird I must admit. Especially at ~1.07, when the sprite is removed and you see all labels clearly, but they still disappear/appear.

The position of the labels are offset from the game object, so when you rotate the game object, they’ll go in/out of the screen along the z axis. You can try using a larger range for your Z values (e.g. -10 to 10) in your render script.

But I agree, if “def” has the same z value as “atk”, then it’s weird.

1 Like

I think it has to do with the sorting inside the engine in combination that you probably don’t have depth test enabled in your render script.

I put together a super quick example, I’ll attach the project as a zip. Let me know if you have any questions!

Project: card3d.zip (35.8 KB)

16 Likes

Those are some neat graphics. Hope you can get it working.

1 Like

You’re referring to the beautiful picture of @sven right? :wink:

3 Likes

yes. and i like it that he has a score of 11 out of 10

2 Likes

Hello everyone,

I’m trying to create the similar animation (flip card) but using Rendercam instead. Is there any way to do this with Render cam instead of the custom render? I try to uncheck the Orthographic checkbox in Rendercam but it doesn’t seem to work!

You have to add rendercam as folder into your project and fix render script as you wish.

UPD: also, in my game I’ve removed some animation where “z-order war” bug was visible and did’t use the predicates for render layers, because some card must be over other, and this trick didn’t fit to solve the issue. Just added biggest value to z in label properties eventually.

2 Likes

You can use a custom render script with Rendercam, as long as you don’t change how it sets the viewport, view, and projection, and a few start-up variables. The easiest way is to copy the Rendercam one into your main folder somewhere and modify it.

Here is one you can try:

rendercam_cards.script (3.1 KB)

  1. Change the file extension back to “.render_script”. (I had to change it to upload to the forum.)
  2. Make a new “Render” file to hook it up (right-click > New… > Render).
    • Set the “script” of the render file to the “rendercam_cards.render_script”.
  3. Open your game.project, under bootstrap > Render, select the new Render file you made.

I just modified the way models are rendered, since it was pretty close already, so it might mess up 3D models if you are using them? I’m not an expert on this at all.

Oh, also, unfortunately you can’t just un-check “Orthographic” on your camera and have it work nicely, you need to change some other settings. To start with I recommend:

  • Set your camera’s Z position to 500.
  • Set “Near Z” to 1, “Far Z” to 1000, and “View Distance” to 500.
1 Like

Wow, thanks all for the quick responses!

I did change some settings after un-check “Orthographic” like Ross suggested, but it wasn’t working. That is because I didn’t change it to such large number as he said, and now it seems to work!

I also got into the “z-order war”, I will try again using the method Dragosha suggested tomorrow, hopefully everything will work as expected!

Again, thanks all for the responses. I read a lot about how Defold has a smaller community but the quality is much better than others, now I now it’s all true! :smile:

Bumping this because the “z order war” of labels is still a problem. Labels need a setting where each glyph can have a unique z position, or maybe offset them per character back and forth by a tiny bit (as a setting) so that they don’t z fight when used in 3d space.

Seems like an awkward solution. How is this handled in other engines?

1 Like

wow thank you sir you made my project easier