InstantiateRandomTrees - janlucakaestle/colabcode GitHub Wiki

Instance of: NetworkController

Description

public void InstantiateRandomTrees()

This function creates trees randomly along the roads up to a certain distance.

Parameters

NumberOfTrees

Can be set in the Unity GUI in NetworkController Tab. Defines the number of trees to be spawned.

DistanceHorizon

Can be set in the Unity GUI in NetworkController Tab. Sets the maximum distance between a road segment and a tree spawning point.

Return Values

Spawns NumberOfTrees trees as GameObjects within the Trees GameObjectParent.

Examples

Tree spawning areas

Trees will spawn randomly in the blue shaded rectangles.

Potential problems

If a road is exactly aligned with the x axis, there might be a problem with the current shape of boxes: Possible solution: read the angle of the road segments and make non-rectangular (e.g. trapezoid) boxes instead.