How to animate an object from World canvas to Overlay Canvas

741 views Asked by At

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

1

There are 1 answers

0
Neliosam On

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