Hi guys,
I need to put a Prefab in to an array of GameObject and make them look at the next one so i declare this:
var prefab: GameObject;
var someObject: GameObject[];
I know how to use Raycast to instantiate a single object like this:
function Update()
{
var hit: RaycastHit;
var ray = Cam.ScreenPointToRay(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
if (Physics.Raycast(ray, hit))
if (hit.collider.name == "Quad2")
GameObject = Instantiate(prefab, hit.point, Quaternion.identity);
And use transform.LookAt() to make transform look at something.
But i don’t know how to instantiate to an array and make them look at and caculate distance to the next one in array and how to destroy the last one in an array.
I really need it.
Thanks in advance.