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 API

Nature Colliders can be created and edited at runtime using the API described in this article. The collider can be accessed using the NatureCollider class, in the following namespace:

using VisualDesignCafe.Nature.Interaction;

Create a new Nature Collider

To create a new collider for interaction, create a game object and then add a collider component and a Nature Collider component:

var gameObject = new GameObject( "name" );
var collider = gameObject.AddComponent<SphereCollider>();
var natureCollider = gameObject.AddComponent<NatureCollider>();

Refresh Colliders

The colliders and bounds for the interaction are cached and are not updated when adding, removing, or changing colliders. If you change the colliders on the object then you have to use "RecalculateBounds" to update the interaction:

// Use "RecalculateBounds" to update the interaction if 
// the colliders on the object changed.
natureCollider.RecalculateBounds( true );

Trail

The trail for the Nature Collider can be changed dynamically at runtime using the following code:

// Set the duration to a value greater than 0 to enable the trail.
// A value 0 or less will disable the trail.
// The value is in seconds. natureCollider.TrailDuration = 1f;
Was this article helpful?
0 out of 0 found this helpful