Prefab being instantiated upside down

Hello,

I’m working on a pong game. I’ve created cubes with textures for powerups, and everything is working ok, except when the cube is instantiated, it is upside down.

Here’s the code for instantiating the powerups:

            // Get a random number to determine which powerup will spawn
			int powerUp = Random.Range(0,4);
				
			// Random number to determine where powerup will spawn on the x-axis, and -13 to get the range between -13, 13
			int xSpawn = Random.Range(0, 27);
			xSpawn = xSpawn - 13;
			
			// Random number to determine where powerup will spawn on the y-axis, and -11 to get the range between -10, 12
			int ySpawn = Random.Range(0, 23);
			ySpawn = ySpawn - 10;
			
			// Spawn powerup 
			if(powerUp == 0)
			{
				Instantiate(growPower, new Vector3(xSpawn, ySpawn, 0), Quaternion.identity);	
				powerUpInPlay = true;
				powerUpAppearsIn = powerUpAppearsInReset;
			}

The powerup prefab rotation is 0,0,0 and if I just drag one of them in, they appear right way up. I’ve tried changing the rotation of the prefabs transform in the hope that two wrongs will make a right, but they stubbornly spawn upside down. Can anyone help? I suspect the problem is related to Quaternion.identity, but I’m new to unity and still trying to get my head around these concepts.

Another thing I’d like to know is why prefabs are instantiated as transforms, rather than gameobjects?

    // PowerUps
	public Transform shrinkPower;
	public Transform growPower;
	public Transform fastPower;
	public Transform slowPower;

Thanks in advance!

grow power was upside down when it was saved in your modelling program

open the object and align it properly in blender/maya etc and it will be aligned properly in unity. mark as answered and have a nice day. :slight_smile:

Make sure in your modelling program you remove all transforms, center your object and remove any rotations. Also make sure the object is exported with Y as up.

Also make sure you are not instantiating the object as a child of another transform, that may cause problems too.

If that still doesn’t work, you can set the default Quaternion of the instantiated prefab in the Instantiate method…

Instantiate(growPower, new Vector3(xSpawn, ySpawn, 0), Quaternion.AngleAxis(180, Vector3.right));   

Play around with the different settings to get it the right way.