all I want to do it code a auto generating game like flappy bird but I am getting errors I have never heard of and as far as I researched I don’t think anyone else has experienced these errors I got 2
Argument 3: cannot convert from ‘(int,int,int)’ to ‘quaternion’
Argument 4: cannont convert for ‘UnityEngine.Quaternion’ to ‘UnityEngine.Transfrom’
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour
{
public GameObject prefab;
public int objectCount;
public float spacing;
public GameObject prefab2;
public int Height;
void Start()
{
var position = new Vector3();
for (int i = 0; i < objectCount; i++)
{
Instantiate(prefab, position, (0, Random.Range(-Height, Height), 0), Quaternion.identity);
position.x += spacing;
}
}
}
I have already tryed turning it into a float and I did not work so am I missing something?
>Solution :
There is no
Instantiate(GameObject, Vector3, (int,int,int), Quaternion)
I suppose you wanted to add random height to position instead setting it as a third parameter. Try
Instantiate(prefab, position + Vector3.up * Random.Range(-Height,Height), Quaternion.identity);
instead.
Also if you need to create Vector3 the "(x,y,z)" is not enough, you have to type "new Vector3(x,y,z)".