Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

During Animation: Object becomes visible (bug?)

Discussion in 'Animation' started by IuliusCaesar, Feb 2, 2020.

  1. IuliusCaesar

    IuliusCaesar

    Joined:
    Aug 31, 2019
    Posts:
    7
    Dear Community,

    I've got the following problem: I've got a grenade GameObject, that is a child to a soldier who throws this grenade. The object becomes visible (SpriteRenderer On) in the middle of the animation and becomes invisible SpriteRenderer Off) again at the end of the animation. So far so good. Playing the animation in isolation works perfectly.
    However, once this animation is played in runtime and the animation returns to the idle animation, the grenade stays visible until the idle animation starts again (then it's invisible again). How can I make sure the grenade stays invisible in the transition between the attack and the idle animation?
    Note: I could probably force the SpriteRenderer off in an update function, but this is frankly taxing and seems rather unelegant.

    Many thanks for your help!

    Yours truly,

    Caesar
     
  2. IuliusCaesar

    IuliusCaesar

    Joined:
    Aug 31, 2019
    Posts:
    7
    Figured it out. The overlap of the animations was such that the re-disabling of the SpriteRenderer did not occur in time. Fixed by drawing out the rest of the animation and disablin the SpriteRenderer earlier.
    I'd still like to know if there is a more elegant solutions...