0

I have a bar on the top of my game with some objects plus the game score, pretty basic and usual. I have some coins (similar to Mario's game) that I would like to animate from the world canvas to the top of my bar that is in a canvas overlay.

By design, the Canvas Overlay is drawn after the camera, so it is on top of my world canvas, so the animation happens to the right position but the object passes behind my menu, not on top of it.

How can I achieve that? To animate an object from my world canvas to the top of an object in a canvas overlay?

This is the my "BAR", the big blue quad behind is the equivalent of my coin and I wish to draw it on top of the small bar.

enter image description here

This is the inspector, the big quad is the object "PieceOfShapeIClone" and the bar in front of it is the "ShapeI" object. Since the "PieceOfShapeIClone" is below it should be rendered on top of the previous objects.

enter image description here

Neliosam
  • 73
  • 11
  • Maybe once the coin has been collected, change its parent to be the overlay canvas? – R Astra Aug 01 '19 at 23:53
  • No success R Astra, even being parented to the bar object it still rendered behind the object. I can check in the inspector that the coin in the correct hierarchy level. – Neliosam Aug 02 '19 at 00:37
  • Try changing the z position or the coin's Sprite Renderer's Order in layer – R Astra Aug 02 '19 at 00:49
  • No matter Z the order I get the same result. Have tried sorting layer with no success also. – Neliosam Aug 02 '19 at 01:40
  • Can you please include a screenshot with the coin gameobject selected, including the hierarchy, scene view (canvas should be visible), and inspector? – R Astra Aug 02 '19 at 01:51
  • Just added the screenshot – Neliosam Aug 02 '19 at 02:11

1 Answers1

0

The "Screen Space - Overlay" does not have any dependency on the camera and it is rendered on top of everything.

The solution was to use "Screen Space - Camera" instead, this will require a camera plus set the "depth" of your canvas to the camera, giving the ability to interact with the objects from the scene.

Hope that this help to assist others with the same issue.

Manual -> https://docs.unity3d.com/Manual/class-Canvas.html

Neliosam
  • 73
  • 11