Hi everyone,
Im very new to unity and I am trying to create 5 of the same game object using a prefab but for some reason it does not work. (Unity - Manual: Instantiating Prefabs at run time iv been using this)
I have done all of the instructions (create cube, add rigidbody and drag it into the prefab) and the code in the script is as followed
using UnityEngine;
using System.Collections;
public class multiboxes : MonoBehaviour {
public Rigidbody boxR;
// Use this for initialization
void Start ()
{
for (int i = 0; i < 5; i++)
{
Vector3 position = new Vector3 (Random.Range (-3.0f, 3.0f), Random.Range (-2.0f, 2.0f), -2.0f);
Rigidbody boxclone = (Rigidbody)Instantiate (boxR, position, Quaternion.identity);
}
}
// Update is called once per frame
void Update ()
{
}
}
I have also made sure that I dragged the prefab into the BoxR rigidbody.
[34725-prefab+data.png|34725]
Any help will be very appreciated.