Search Unity

Bending a sprite in this way? How to make trees sway in 2D?

Discussion in 'Animation' started by cinnamonrollapplecider, Jul 12, 2022.

  1. cinnamonrollapplecider

    cinnamonrollapplecider

    Joined:
    Jul 6, 2017
    Posts:
    9


    I'm trying to create this effect in my game. I think that it might be done with Sprite Editor and soft bodies, but I feel I could be missing something very simple - like using a Spring Joint that goes all the way through the asset. Could anyone provide any insight into how this effect it is done?

    If it is done with soft bodies, how would these be rigged? Would it simply be one bone going through the middle and deforming it? Or is it even a shader?

    I've tried to rig my tree, and then add force using AddForce by applying an impulse on the left-hand side of the tree. But it doesn't seem to work.
     
  2. katherine97

    katherine97

    Joined:
    Jul 12, 2022
    Posts:
    1
    Great question! There are a few ways to accomplish this. To get the tree to bend, you need to reduce the sprite's thickness and create a sprite that is skewed to a single angle. Then you fade it in and out, depending on the Sprite's angle and direction. This can be easily accomplished using the Prefab.
     
  3. cinnamonrollapplecider

    cinnamonrollapplecider

    Joined:
    Jul 6, 2017
    Posts:
    9
    Hi Katherine, thanks so much for providing an answer. When you say, getting the tree to bend, and reducing the "thickness" do you mean, making it thinner around the x-axis (so squeezing it, basically)?

    I'm not sure how they are fading it in and out here? How does it look so seamless as it bends?