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

Making foliage wave in a 2D game with wind

Discussion in '2D' started by AlexTemina, Jul 29, 2016.

  1. AlexTemina

    AlexTemina

    Joined:
    Feb 19, 2014
    Posts:
    44
    Hi,
    We made a post in our blog talking about how to make foliage wave in a 2D game, and I thought it would be very nice to share it with the community.

    http://blog.moondrop.no/2016/07/making-foliage-to-wave-in-a-2d-game-with-wind/

    I hope you enjoy the reading. It comes with a bundle with all the code and assets inside.

    I was not sure if this post should go to 'Work in Progress' or 'Showcase'. In that case, apologies and you can move it.
     
  2. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Love this!!! thanks for sharing
     
    AlexTemina likes this.
  3. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Could you tell me how I can affect the wave depending on the player, like shown in the example ?

    thanks
     
    AlexTemina likes this.
  4. AlexTemina

    AlexTemina

    Joined:
    Feb 19, 2014
    Posts:
    44
    I'm glad you liked it :)

    Yeah, just think that now you have to "inyect" force to the waver from many sources. To add the force from the players, write a TriggerEnter2D and check if the trigger is done by the player. If it is, then you can add force depending on the velocity of the player. Then on OnTriggerExit2D you remove that force.
     
  5. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    This is fantastic, many thanks for sharing! : ]
     
    AlexTemina likes this.
  6. AlexTemina

    AlexTemina

    Joined:
    Feb 19, 2014
    Posts:
    44
    Glad you like it, you are very welcome!
     
  7. BlueSin

    BlueSin

    Joined:
    Apr 26, 2013
    Posts:
    137
    Great job on this AlexTemina, thanks for sharing!
     
    AlexTemina likes this.
  8. rubendariohh

    rubendariohh

    Joined:
    Oct 14, 2017
    Posts:
    32
    Hi, I followed all the steps but is not working for me. I´m using the prefab you included in the package but when playing the scene the plant is not waving at all. I´m using Unity 2017. Any Suggestion? thanks!
     
  9. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    A download package would be welcome so we can just try it out :)