Trying to work out how to move child object in animation to a world position?

So i’ve completed the animation event but im trying to polish the animation by making the star child move to the Star Displays world position.

I’ve recorded the transform position for the star but obviously depending on the position of the trophy prefab, the animation will end in a position relative to the parent.

What i really want is to make sure that wherever the trophy is placed on the grid, the star should then move towards the star display in the bottom right of the screen and fade out.


^^ heres what I want to happen

heres the starting postion ^^^

heres where they end up one the animation gets to the end ^^^

Hopefully you can see my issue from the screenshots attached :slight_smile:

1 Like

Hi! Welcome to the community!

I don’t think you can animate that, you’ll have to code it.

First, you’ll need the position of the UI object, that will return a screen position, so you’ll have to convert it into a world position, the rest is kinda simple, just use the MoveTowards method of the Vector2 class.

If you want a neat curve animation for when the stars move, you could use blend trees and an animation, or go full math.

Hope this helps!

[Edit]

Actually you know what, you can totally animate that. But you have to make the star independent of the trophy object, you’ll have to instantiate the stars instead. That could work.

I don’t like this approach because this means you’ll have to change the animation if you change the position of your UI, and also it won’t look as neat with different resolutions since the UI changes it’s position slightly and also it’s size. I rather go with code for this one.

Glad to be here!
Thanks so much! Been scratching my head for around an hour playing around with it, i’ll give it a go and reply back if it’s gone well

Really appreciate the help!

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms