Making straight hedges.

Hi, I’m testing to use Unity for some interactive architecture visualisation, and need to be able to create straight rows of hedges. The Unity terrain tool doesn’t allow me to paint straight or with a brush smaller than 1m. Ideal would be if I could import my own splatmap or something. I’m happy to pay for any asset that can solve this. Any ideas?

Worst case scenario I’ll import a mesh acting as a ground plane for the rows of hedges, and instantiate the hedge objects along this mesh via script and then delete it. But it seems like there should be an easier solution to this.

I made a HedgeMaker script to solve this, here’s the code if anyone would need anything similar. Your scene needs a GameObject called HedgePoints with a number of nulls that make up the start and end of the hedges. Every second null counts as a start of a hedge. The rest should be self-explanatory.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


[ExecuteInEditMode]
public class HedgeMaker : MonoBehaviour
{

    public List<Vector3> ends;
  
    public GameObject bush;
    public float distanceBetween;
    public float randomSize;

    public bool showHedges = false;
    public bool deleteHedges = false;

    private List<Vector3> points;
    private List<GameObject> hedges;
    private float dist;
    private Quaternion rot;
  
    private GameObject HedgePoints;

    void Start ()
    {
        hedges = new List<GameObject> ();
    }

    void Update ()
    {

        points = new List<Vector3> ();
        ends = new List<Vector3> ();

        HedgePoints = GameObject.Find ("HedgePoints");

        foreach (Transform child in HedgePoints.transform) {
            ends.Add (child.position);
        }

        for (int i = 0; i < ends.Count-1; i++) {
            if (i % 2 == 0) {
                dist = Vector3.Distance (ends [i], ends [i+1]);
                for (int j = 0; j < dist / distanceBetween; j++) {
                    float distP = (float)j / dist * distanceBetween; //here I want
                    Vector3 currentP = Vector3.Lerp (ends [i], ends [i+1], distP);
                    points.Add (currentP);
                    points.Add(ends[i+1]);
                }
            }
        }

        for (int i = 0; i < hedges.Count; i++) {
            try {
                hedges [i].transform.position = points [i];
            } catch (Exception e) {
            }
        }


        if (showHedges && !(hedges.Count == points.Count)) {
            MakeHedges ();
        }

        for (int i = 0; i < hedges.Count; i++) {
            if (!(hedges [i] == null)) {
                if (showHedges) {
                    hedges [i].SetActive (true);
                }
                if (!showHedges) {
                    hedges [i].SetActive (false);
                }
            }
        }
        if (deleteHedges) {
            DeleteHedges ();
        }
    }

    void MakeHedges ()
    {

        hedges.ForEach (child => DestroyImmediate (child));

        hedges = new List<GameObject> ();

        for (int i = 0; i < points.Count; i++) {
            rot.eulerAngles = new Vector3 (0, UnityEngine.Random.Range (0, 360), 0);
            hedges.Add (Instantiate (bush, points [i], rot));
            hedges [i].transform.SetParent (gameObject.transform);
            float sizeChange = UnityEngine.Random.Range(-randomSize,randomSize);
            hedges[i].transform.localScale += new Vector3(sizeChange,sizeChange,sizeChange);
        }
    }

    void DeleteHedges ()
    {
        hedges.ForEach (child => DestroyImmediate (child));
        hedges = new List<GameObject> ();
        deleteHedges = false;
    }


    void OnDrawGizmos ()
    {
        Gizmos.color = Color.blue;
        for (int i = 0; i < points.Count; i++) {
            if (points [i] != null) {
                Gizmos.DrawSphere (points [i], .1f);
            }
        }
        for (int i = 0; i < ends.Count-1; i++) {
            if (i % 2 == 0) {
                Gizmos.DrawLine (ends[i], ends[i+1]);
            }
        }
    }
}