- Home /
Is it possible to move a transform to a specific point on a sprite animation every frame?
I've spent the past couple of days trying to figure out a way to move a transform to match a moving point on a sprite animation drawn frame by frame. The transform would move to a new point on the animation each frame so that the characters head can animate independently of the body.
Just wondering if anyone knows of any paid software or good tricks for achieving this? This locator system would be perfect: https://www.youtube.com/watch?v=69RT3g8HH3k but doesn't use the modern Unity animation system.
I've looked into using animation events but have found them quite difficult to work with/ unreliable so far.
Ideally I'm looking for something like the pivot in the sprite editor, but a whole separate one just for attaching child objects to each frame. I wouldn't mind doing some time-consuming typing in of offsets for each frame if it would work quickly enough.
Thanks very much!
Romano
EDIT:
My current solution is to use the sprite from the sprite renderer as a key in a dictionary which equals the desired point on the sprite as a vector2. It'll take ages doing it this way, and I don't know what impact checking the dictionary every frame of the animation will have on the performance so would still appreciate advice from anyone on how I can do this better.
Answer by carrollh · Jan 23, 2015 at 03:21 AM
That looks like he's just put some empty GameObjects as children of the main sprite GameObject. So when the thing moves they travel along. Then just tied a particle effect to each one.
You could create a custom Animation for each of these GameObjects that you could set to only last x frames. I'm not sure they would be perfectly timed though. To do that you would just select the GameObject for the foot, press ctrl+6 then add a new curve, and edit the keyframes. It sounds a lot harder than it is. Video tutorial for the Animation Panel: YouTube
It actually does look like he's done that! But each frame actually has its own different transform position, the example he's used is pretty bad at showing what its really doing.
$$anonymous$$aking separate animations themselves could be good, I'll give that a try thanks.
I hope you don't take this the wrong way, but you are a fucking wizard. Thank you! That worked instantly :)
Your answer
Follow this Question
Related Questions
Changing the pivot point of meshes. 12 Answers
pivot not exporting 0 Answers
How to get distance from position to transform bounds 1 Answer
Animation rotation problem. 0 Answers
Simple LookAt Rotation with offset pivot 2 Answers