Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading