'unity says it can't convert (int,int,int) into a quartinon [closed]

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 1:[1]

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)".

Solution 2:[2]

The declaration of Instantiate you are using takes 4 parameters so it must match this:

public static Object Instantiate(Object original, Vector3 position, Quaternion rotation, Transform parent); 

The last two parameters are Quaternion rotation & Transform parent. Looks as though you need to put the Quaternion.identity as the second to last parameter and set the Parent transform as the last.

Instantiate(prefab, position, Quaternion.identity, PARENT);

Solution 3:[3]

your are calling Instantiate with 4 parameters which has parameters as

Instantiate(GameObjectToInstantiate, PositionInVector3, RotationInQuaternion, transform);

for that reason unity is expecting Quaternion in third parameter but your are passing (0, Random.Range(-Height, Height), 0)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pawe? ??gowski
Solution 2 Nathelol
Solution 3 Digvijaysinh Gohil