I am struggling with this for a while now and wondering if anyone can point me in the right direction.
Trying to instantiate a prefab in each vert of a mesh with C#.
When I call the “Instantiate” function it doesn’t recognise the “vertices” variable as it seems to conflict between “Vector3[ ]” and “Vector3” …which totally puzzles me.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Instantiator : MonoBehaviour {
public GameObject dot;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update() {
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
int i = 0;
while (i < vertices.Length)
{
vertices[i] += Vector3.up * Time.deltaTime;
i++;
}
mesh.vertices = vertices;
mesh.RecalculateBounds();
Instantiate(dot, vertices, transform.rotation);
}
}
Thank you