Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

What would be your preferred way to animate a growing plant?

Discussion in '2D' started by Daerst, Feb 27, 2020.

  1. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    In my Unity 2D game, I have a plant (imagine a beanstalk or any other thick tendril) that starts small and should grow through animation. I want the base of the plant to be static, and the tip to extend and grow following a smooth path. Bonus points for some leaves popping out here and there.

    I tried animating a Sprite Shape path, but Unity's Animator can't modify the spline, unfortunately. I still could do it from code, I guess. Or rig the whole thing and somehow hide most of it behind a Sprite Mask in the beginning. Or maybe timeline can help? Sounds like a good idea to combine the growing tendril with the emerging leaves.

    What would be your take on an animation like this?
     
    Last edited: Mar 5, 2020
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,345
    Cant you just make all the sprites for the animation in whatever graphic editor you are using? Maybe I am not understanding exactly but I think it would be way easier to just do all of the sprites for the animation in Gimp or Photoshop or w/e.
     
  3. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    I would recommend using the new 2D animation system. You can use their tool to auto-rig your 2D sprite and adjust as needed. Then you create some bones that control the stretching and expanding using the bone position/scale. Finally, you use the Unity Animator to move the bones, and the rigged Sprite will animate accordingly.

    This article is a little over a year old, but the few short videos on it can sorta show you how this animation package works before you decide to put time and effort into using it. https://blogs.unity3d.com/2018/11/09/getting-started-with-unitys-2d-animation-package/
     
  4. TimBur

    TimBur

    Joined:
    Jan 17, 2013
    Posts:
    35
    The new SpriteShape package is great for curved shapes, and for procedural animation of those shapes. There isn't much scripting-oriented documentation on the package, so you need some C# skills to make it work, but I think it would do what you need.

    SpriteShapes are based on splines. If you create an open-ended SpriteShape, you have a wiggly line. You can grab and reshape that line by hand, via Editor. You can also can procedurally reshape that line via code. You would likely need to add leaf-sprites and flower-sprites separately. Ex: In your procedural script, create a separate, child leaf-sprite-object for each SpriteShape node, and then procedurally place that sprite at the node. Still, the SpriteShape could be a good core idea for a narrow plant, like a sunflower or a vine.