New: Nature Renderer 2021

Render vast amounts of detailed vegetation on your terrain.

Learn more
This page may not work correctly inside the Unity editor. Open in browser

Interaction

nature-shaders-interaction-loop.gif

Requires the full Nature Shaders package.

Not supported in Nature Shaders Essentials. (Learn more)

Vegetation that uses the "Grass" or "Plant" shader can interact with other objects in the scene. The vegetation will be pushed down when an object moves through it, and will sway behind the object once it has passed.

Note that interaction is not supported for trees and is recommended only for small grass/plants. As a general rule of thumb: if the plant is larger than the player then it probably should not have interaction enabled.

Follow these steps to enable interaction:

For the vegetation object:

Recommended: Create a Nature Asset for your prefab or model to automatically set up interaction.

For manual setup, follow the steps below:

  1. Select the material of the vegetation, and ensure that it is using the "Nature Shaders/Grass" or "Nature Shaders/Plant" shader. Note: For URP and HDRP the shaders are in the "Universal Render Pipeline" or "HDRP" sub-category.

    nature-shaders-supported-shader-for-interaction.jpg
  2. Scroll down to the "Interaction" section in the material editor, and enable interaction.
    nature-shaders-enable-interaction-for-material.jpg
  3. The interaction feature needs to know the shape of the model to correctly calculate interaction with objects. The shape is loaded from the Mesh section in the material. If you created a Nature Asset then this will be set up automatically, if you manually created the material then you may have to tweak the object size and radius in the Mesh section.
    nature-shaders-material-editor-mesh.jpg
  4. (Optional) Tweak additional settings in the material, such as the interaction strength, the time it takes for the vegetation to settle, or others. See the Material Editor article for a full list of settings that can be tweaked for the material.
    nature-shaders-material-editor-interaction.jpg

For scene objects:

  1. Select the game object in the scene that you want the vegetation to interact with.
  2. Add a collider to the game object, if it does not have any colliders. The colliders are used for interaction.
    Tip: Set up a Collision Layer if you want the collider to only interact with vegetation and not with other objects.
  3. Add a Nature Collider component. This component will register the colliders on the object as colliders that should interact with vegetation.
    Note: Only the colliders on the same game object are registered. Colliders in children are not registered.
    nature-shaders-add-nature-collider.jpg
  4. That's it, the vegetation should now interact with the object and sway when the object moves around. Both in edit-mode and at runtime.
    nature-shaders-interaction-loop.gif

 

 

Was this article helpful?
6 out of 8 found this helpful