Hey,
I want to use the Instansiate function to clone a prefab.
I have a empty parent object that should emit those prefabs.
But when I want to Instantiate the object, the function wants me to enter a Transform and
not a Vector3. I don’t understand this error because in the Documentation it says that it should work with a position and a object assigned.
GameObject logPrefab;
GameObject spawnObject;
string logPath;
Vector3 spawnPosition;
// Use this for initialization
void Start()
{
spawnObject = GameObject.Find("obstacleSpawn");
logPath = "models/log";
logPrefab = (GameObject)Resources.Load(logPath);
Debug.Log(logPrefab);
createWoodLog();
spawnPosition = new Vector3(14, 27, 12);
}
// Update is called once per frames
void Update()
{
}
void createWoodLog()
{
Instantiate(logPrefab, spawnPosition);
}
And the error
Assets/Resources/script/SpawningScript.cs(39,9): error CS1503: Argument `#2' cannot convert `UnityEngine.Vector3' expression to type `UnityEngine.Transform'