It is necessary to animate a group of elements, namely (image + text) for some distance up and disappear. The problem is that the text is on the GUI layer. Clearly what is required. I am writing a clicker and by clicking on the mouse, the currency icon + text should be shown, how much has been given, and this is all moving. UPD: you need to implement floating text
3 answers
"on the GUI layer" if it meant that you use the GUI, then my advice to you is to switch to the UI many times easier. When using the UI, you attach (make a child) in the image (currency icon) text and only animate the image, and the text as a child will have the same effect.
- Not quite strong in terms of unity yet, just started. Yes, I use UI. I tried it, I got a "one-time" animation, that is, if the image is left on the scene, the animation will play and everything is fine. But in the future I need to create this prefab and move it by clicking. That, alas, I can't do it - Rostislav Vasilenko
Understood with this. It turned out like this:
An empty gameobject is created on the scene. Next, add a Canvas → Image → Text . Created Prefab. (for convenience, it is better to change the scale canvas. In my case, the value of 0.005 approached). In the script where mouse clicks are tracked we create an object according to the coordinates of the mouse and destroy it after 2 seconds (any time).
- And what were they ashamed to put the animation code? That would be the way) - Alexey Shimansky
- @ Alexey Shimansky, I advise you to read my answer and get an even more beautiful result - Kiya
- @Kiya I personally do not care - Alexey Shimansky
- Using the GUI is a bad idea. This is a bad and outdated technology. It is very slow and inconvenient in work (convenient for tests like displaying FPS). Use NGUI (Canvas + UI Objects)
- For animations of this kind I advise you to use the free LeanTween asset. It is very easy to use + has different options for animations (look for Ease if you want a beautiful animation). It is easy to use and very fast.