Hi
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?
EDIT
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;
//movement
Vector3 randomDirection = new Vector3(Random.Range(-1, 1), 0.0f, Random.Range(-1, 1));
rigidbody.velocity = randomDirection * speed;
}