Author Topic: Animations and Anchors, again :)  (Read 6124 times)

electrodruid

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 48
    • View Profile
Animations and Anchors, again :)
« on: May 08, 2013, 09:01:47 AM »
I've read the other threads about animations and anchors, and know that you're only supposed to add animations to the children of objects with anchors (not the objects themselves or their parents). But consider this setup:

UIRoot
-- Camera
---- Anchor
------ Panel
-------- SpriteA (has an Animation which moves its position)
-------- SpriteB (anchored to Sprite A)

This should be okay, right? SpriteA doesn't have an anchor, or any children with anchors, and spriteB doesn't have any animation. SpriteA should move and SpriteB should stay anchored to SpriteA, and so should move along with it. Yes?

It almost works, but there's weirdness. There is a noticeable lag in SpriteB as SpriteA moves, and B even seems to "overshoot" and snap back into place at the end of the animation. Additionally, Unity doesn't seem to be displaying SpriteA's transform properly. If the animation just changes SpriteA's transform.position.y from 0 to 300 over two seconds, SpriteA moves just fine but all the inspector windows shows is a transform position of (-0.2119612, 18, 0) - i.e. garbage. If you click on the transform in the inspector after the animation has happened then it refreshes to the correct values (0, 300, 0).

The use case for this was our old friend the dialog box. SpriteA would be a sprite representing the box background, and SpriteB would be a widget anchored to some point inside the dialog (but not a child of it). Obviously there could be many such widgets. Having to animate every single thing in the dialog individually seems like a massive pain, but this visual lag/overshoot of the anchors is pretty sloppy-looking. What is the solution?

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Animations and Anchors, again :)
« Reply #1 on: May 08, 2013, 11:54:50 AM »
What about creating a Panel animation to move SpriteA and B, so they're in the same animation.


laurentl

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 188
    • View Profile
    • McDROID
Re: Animations and Anchors, again :)
« Reply #2 on: May 22, 2013, 06:11:32 PM »
I think this is related to a glitch of the ANimation component:
if your anchor itself moves as a result of an animation, the anchored object will see its position baked by the Animation component if you scrub the animation!

Yes it's quite incredible isn't it.

Does anybody know a way to turn off the animation auto bake ?

electrodruid

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 48
    • View Profile
Re: Animations and Anchors, again :)
« Reply #3 on: May 22, 2013, 06:14:35 PM »
For what it's worth, jeldrez' solution of just animating the panel rather than SpriteA worked for me.

laurentl

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 188
    • View Profile
    • McDROID
Re: Animations and Anchors, again :)
« Reply #4 on: May 22, 2013, 06:54:09 PM »
Ouch, 10s of object need to be moved to panels? :(
Will try