How can I get nearest foliage?

Is those transform somewhere?

For example lumbercamp worker has to cut a tree

Heya,

The trick with foliage is that InstanceFoliage is a sub-class of InstancedStaticMesh. If you cast your foliage to a instancedStaticMeshComponent, you can perform all the usual instance functions. Don’t forget foliage has NoCollision set by default, so give it something.

In the screenshot attached I am getting all actors around me, and printing their transform. If you want to get the nearest foliage, you could get those around you and store them in an array, and sort the array (various posts on here for sorting arrays or finding closest). The HitItem pin on a hitResult returns the index of the instance.

1 Like