Reputation: 67
Note: Incase you get confused, playership_1 is the enemy prefab, it just won't let me change the name
I am making a laser defender game in my online course (2D) and so what we are doing is instantiating, and/or spawning enemies as children of positions that are marked by gizmos. When I start the game, it looks like this:
When I start the game, I only see the spaceship and the black background. When I pause and go into the scene, this is what I see:
I have checked the z-value, even though I don't have a background. What is wrong? Please help.
Upvotes: 1
Views: 728
Reputation: 4620
If you take a closer look at playerShip1_blue in your image the scale is set to 0 0 0
. So my guess is that all your instantiated gameobjects has the same scale.
transform.localScale = new Vector3(1f,1f,1f);
Add this code above to the GameObject
you instantiated and you should see the playerships in your game
Why this is happening and a better solution to the problem is to stop using transform.parent = transform;
and use transform.SetParent(transform);
I found a good explanation here and please read it http://answers.unity3d.com/questions/868484/why-is-instantiated-objects-scale-changing.html
Upvotes: 1