Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Assets [FREE] Foliage 2D - Create foliage animation and regions of foliage along a path

Discussion in 'Works In Progress' started by Nicrom, Jun 30, 2015.

  1. sergioschiavo

    sergioschiavo

    Joined:
    Feb 11, 2014
    Posts:
    24
    Great, thanks for that. I have seen it here now, it's nice that you took care of well commenting the code.

    I will work on a few modification. I have a few ideas in mind. Also would like to add a field in the inspector to select which game objects (tags) can trigger the foliage bending 'animation'.

    I can share with you when I'm done in case you are interested.
     
    Kirbychwan and Nicrom like this.
  2. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    346
    Thank you for the offer to share your changes with me. If you have any more questions you can message me directly on my email johnq002@gmail.com
     
  3. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    22
    First of, can you please update the web player examples? The links doesn't exist :(

    1. Is it possible (or you've already implemented?) a type of "global wind"? So we can set weather. This could go in hand with what seriosachiavo said: "...offset without the need to create animation"
    2. and what zenGarden said almost three years ago: "...to have the foliage automatically adapt and follow some terrain sprites layer, clicking would raycast below and place the foliage above terrain 2D collision tiles"

    I think this asset is VERY important as there is no other 2D foliage asset out there!!! And your way is the best, otherwise we'd have to learn how to code shaders -.-

    Awesome work on the Water 2D asset btw!
     
  4. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    346
    Hi.

    I did not even notice the links were broken, thanks for pointing this out.

    Currently I am busy with other projects so I'm not when I'll start working on Foliage 2D add new features.
     
  5. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @Nicrom I'm not certain if this is supported anymore; but I did have a question regarding performance.

    When I have a lot of grass animating in a single scene, performance more or less plummets. I did some stress testing, and I've enabled completely culling the animation on the Animator components on the Prefabs (as to stop them unless they're visible on screen!), but it seems like the animation for every piece of foliage is still being animated every frame, for some reason.

    upload_2018-9-6_17-8-47.png

    Any ideas?

    Update:
    We ended up implementing a sort of secondary culling system to disable the animations whenever they were off screen, which seems to have saved significant performance.

    That being said, there seems to be a bug where if you duplicate and place Foliage paths, you get weird behavior, like foliage from one path actually belonging in another path, or sharing colliders for being moved through.
     
    Last edited: Sep 8, 2018
    Robiwan likes this.
  6. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    346
    Hi.

    I'm sorry for this really late reply. For some reason I didn't receive a notification about a new post on this forum thread.

    Disabling the animations or the the game object is what I was going to suggest :).

    It's best to create a new path object and not duplicate an existing one.
     
  7. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    346
    Foliage 2D is no longer a paid asset and can be downloaded for Free
    Currently I am busy with other projects and do not have the time to add new features to this Unity extension, as a result I decided to make it free.

     
    Last edited: Feb 1, 2019
  8. liveswithoutfear

    liveswithoutfear

    Joined:
    Sep 4, 2018
    Posts:
    5
    Hey, Nicrom. I've been using your Foliage asset and I have to say it's amazing. It's saved me so much performance over using terrains, which seemed to be slowing my game down dramatically on lower end devices, using your asset has given me upwards of 10FPS.
    However I have the same problem with instantiating gameObjects with the Foliage animation on as a prefab.
    If I write
    1. Foliage2D foliage2D = instantiatedObject.GetComponent<Foliage2D>();
    2. // The object mesh is recreated so that we don't have 2 objects with the same mesh instance.
    3. foliage2D.RebuildMesh();
    into a start function on the Foliage2D script I get an error, "the name 'instantiatedObject' does not exist in the current context"
    If I just write "RebuildMesh();" into a start function that does work on instantiated objects, but everything that wasn't instantiated now doesn't animate.
    What am I missing. Sorry if this is an obvious one.
     
  9. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    346
    instantiatedObject doesn't exist in the Foliage2D code. I used this as an example. You have to replace instantiatedObject with what you name your new foliage instance.
     
  10. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    345
    Hello @Nicrom
    Do you know if this should work with URP and 2D Renderer?
    I can't seem to get my foliage mesh to animate in my project.

    Running 2019.3.5f1, URP 7.1.8
     
  11. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    346
    Hello @rxmarccall,

    It should work.The mesh deformation is done on the CPU, so what scriptable renderer pipeline you use is not important.

    Does the Foliage 2D demo scene work in your project. If it does, it's posible the problem is in the shader you use on the foliage objects.
     
unityunity