Done Something Wrong, Don't Know What I've Done?


I’ve got my asteroid, when i shoot it it should be destroyed and instantiate 4 more in its place. To do that I have created 4 empty game objects around my asteroid to spawn the others. I’m only using the X and Z axis as it is top down so they should spawn at 0 on the Y.

I was trying to make the asteroids bounce of other objects so I added a bouncy physic material. Next thing I know the asteroids instantiate all over the y axis? I froze position on the Y axis in rigidbody and took bouncy off but its still doing it. All spawn points are at 0 on the Y yet the asteroids instantiate off of 0 which they didn’t before?

Any ideas what I could have done?

I’ve taken the code that deals and may affect with the instantiation issue.
Asteroid Controller deals with instantiating.

The spawnUpper and spawnLower etc is looking top down so it differs on the X rather than on the Y. If that makes sense.

        public GameObject mAsteroid1;
    	public Transform spawnUpper;
    	public Transform spawnLower;
    	public Transform spawnLeft;
    	public Transform spawnRight;
        void OnTriggerEnter (Collider other)

            Destroy (other.gameObject);
		    Destroy (gameObject);
            Instantiate(mAsteroid1, spawnUpper.position, transform.rotation);
    		Instantiate(mAsteroid1, spawnLower.position, transform.rotation);
    		Instantiate(mAsteroid1, spawnLeft.position, transform.rotation);
    		Instantiate(mAsteroid1, spawnRight.position, transform.rotation);

Asteroid Mover

void Start ()

		//random rotator
		rigidbody.angularVelocity = Random.insideUnitSphere * tumble;

		Vector3 randomDirection = new Vector3(Random.Range(-1, 1), 0.0f, Random.Range(-1, 1));
		rigidbody.velocity = randomDirection * speed;

Without code its a bit of a chore to understand whats going on …

You can try one thing :

  1. In the game view Unselect Maximise on Play.
  2. Then run your scene and when the wrong kinds of object instantiate
  3. Press the pause button.
  4. Select the initialised game objects by selecting them in hierarchy view on the left panel.
  5. Check the properties of the new instantiated game objects and you might be able to trace whats gone wrong.
  6. Then you can also disable renderers selectively is there are too many object.
  7. You can always pause and modify on runtime till the point you discover where you went wrong.

Hope this helps.

I worked out whats gone wrong. The spawn points seem to be rotation with the asteroid meaning the spawn points are changing regarding the Y axis. Don’t know why its doing that as it wasn’t before so I’ve just got to work out how to stop those rotating but still following the asteroid.