Collider System

Collider System

The Collider System Component creates run-time colliders for tree, objects and large objects. It needs to be added to the same GameObject as the Vegetation Systen Component.
Collider Info
Layers
Debug Info
Configure colliders on Vegetation Items
Collider events

Collider System Inspector

Sceneview showing current mesh and capsule colliders on rocks and trees.

Collider Info

Collider system

Collider system setting is used to decide the selection process for colliders. Currently only 2 modes are available.

  • Disabled
    No colliders are instanced.
  • Visible
    All colliders on Vegetation Items with enabled colliders are instanced when visible. This also includes items behind camera on partial visible cells.

Range

Visible colliders within range are instanced/destroyed as camera moves around the scene. Distance is based on Vegetation distance on Vegetation Studio Component. Normal is 20%. Long 40% and Very Long 100% of range.  Make sure you limit the range to what you need as it requires time to create and handle colliders.

Layers

Select the layer for the created colliders, each Vegetation Item Type can have a separate layer.

Navmesh

It is possible to bake out all colliders configures on the individual VegetationItems. This allows you to use those to generate an Unity NavMesh. When navmesh is baked you can remove the colliders from the scene.

There is 2 options for exporting the colliders to scene. Bake as colliders and bake as scene mesh.
The mesh export will convert all colliders to meshes. This is what the Unity Navmesh uses to bake.

Debug Info

Option Show included cells will show the selected vegetation cells used to create run-time colliders. Selection is based on camera viewpoint and Range setting.

Included cells and colliders are based on current viewpoint.

Sceneview showing terrain in play-mode. Vegetation cells within Normal range.

Configure colliders on Vegetation Items

In order to configure the colliders for each Tree, Object or large object go to the Vegetation tab on the Vegetation Studio Component.

Collider events

There are 2 events you can connect to to get informed when a run-time collider is created. Use them to add any custom components you need to the collider GameObject. Like dynamic obstacles for path finding or resource scripts for gathering etc.

[enlighter lang=”csharp”]

public delegate void MultiCreateColliderDelegate(Collider collider);
public MultiCreateColliderDelegate OnCreateColliderDelegate;

public delegate void MultiBeforeDestroyColliderDelegate(Collider collider);
public MultiBeforeDestroyColliderDelegate OnBeforeDestroyColliderDelegate;

[/enlighter]

To connect to the events.

[enlighter lang=”csharp”]
void Start()
{
colliderSystem.OnCreateColliderDelegate += OnCreateCollider;
colliderSystem.OnBeforeDestroyColliderDelegate += OnBeforeDestroyCollider;
}

void OnCreateCollider(Collider collider)
{
//Your code here.
}

void OnBeforeDestroyCollider(Collider collider)
{
//Your code here.
}
[/enlighter]