Home > Enterprise >  how do I make an Instantiate function with 4 parameters
how do I make an Instantiate function with 4 parameters

Time:04-03

I am trying to make an Insatiate Function but it isn't really working it is suppose to make an platformer spawn but there is an error saying: Cannot Convert From '(int, int, int)' to 'Transform'

for (int i = 0; i < objectCount; i  )
        {
            Instantiate(prefab2, position, Quaternion.identity, (0, -Height, 0));
            position.x  = spacing;
    }

CodePudding user response:

If you take a look here: https://docs.unity3d.com/ScriptReference/Object.Instantiate.html at the Declaration it says:

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

The fourth argument you have is (0, -Height, 0) which is (int, int, int).
But it wants a Transform. (The Transform of the Parent it should have)

I dont know what you want with (0, -Height, 0), maybe you could clear up?

  • Related