Search Unity

Strange bug with anchored position property in Animation

Discussion in 'Editor & General Support' started by vladrybak, Jul 5, 2015.

  1. vladrybak

    vladrybak

    Joined:
    Aug 30, 2013
    Posts:
    108
    Hello, i found a strange bug (in Unity 5.1.1) when add anchored position property of RectTransform in My Animation.
    1. I use scripting to Moove Unity UI object to certain position;
    2. I need to use OnPointerEnter/Exit Animation when object on this position;
    3. When Animator disabled object mooves just as expected.
    4. When i enable Animator, object mooves only in scene view, and after that return to it's start position, even if animation is not called. Is this a bug or i'm misunderstand something?
    Project with the problem attached. Load Bug scene, press a button and check unexpected behaviour of white square.
     

    Attached Files:

  2. vladrybak

    vladrybak

    Joined:
    Aug 30, 2013
    Posts:
    108
    Nobody knows? Does it mean, that i can't use animator on UI object, and simultaneously move object by script? For example, if i have an animator with a couple of animation states, in a first state an object's width is changing, a second state change object's position. I need to move object by script and use a first animation while it's moving, and after that, when object on a certain position, i need to use a second animation. Now it's not possible, because when animator is enabled, even if no animation plays, object's anchored position taken from a second animation start point, where anchored position property is set.
    Sorry for my bad english, but did somebody understood me?
     
  3. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    It's a general issue that you can't simply use script and animator for same purposes.
    Some workaround is to create an empty state with no animation.
    While in that state your object will follow the script.
     
  4. vladrybak

    vladrybak

    Joined:
    Aug 30, 2013
    Posts:
    108
    The problem is that workaround is not working with ui objects. Even when animation is in default empty state, object still takes anchored position from other animation.
     
  5. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    Another possibility is to deactivate the animator via AnimationEvent.
    Try out if that works for you.
     
  6. vladrybak

    vladrybak

    Joined:
    Aug 30, 2013
    Posts:
    108
    If i deactivate animator i'll be unable to play any animations. But i need to control object width by first animation, and move object by script, and then move object by second animation.
     
  7. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    have you tried to put the position calculating script on the animation itself via animationstatebehavior?
    I would try that out myself but I am far away from home;)
    Strange thing is, it worked fine with a new created cube, simple rotateing animation and moving script (while animator is in empty state) But as soon as I added some animations from another animator and reorganized the referenced objecrs, it screwed up everything. maybe it is only possible if you do it feom scratch
     
  8. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    have you solved your problem? I found some hidden animator state with animations of the main object that blocked the script.
    It worked perfectly again after deleating it.
    But last thought, have you checked "Write defaults" in the animation state?
    The last resort is to make a animator from scratch.
     
  9. vladrybak

    vladrybak

    Joined:
    Aug 30, 2013
    Posts:
    108
    No, I have not solved this problem. I just made animation via script. And report a bug
     
  10. adrianmaven

    adrianmaven

    Joined:
    Jul 13, 2015
    Posts:
    1
    The bug is still valid in 5.2.2, very very annoing
     
  11. ireth_86

    ireth_86

    Joined:
    May 18, 2016
    Posts:
    23
    Last edited: Sep 27, 2016