Астеройды

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class AsteroidBeltGenerator : MonoBehaviour {
	
	public float rndPositionX;
	public float rndPositionY;
	public float rndPositionZ;
	public Transform Asteroid1;
	public int Asteroid1Count;
	public float Asteroid1MinScale;
	public float Asteroid1MaxScale;
	private float _1scale;
	private Vector3 Asteroid1CurScale;
	private float cur1RndPositionX;
	private float cur1RndPositionY;
	private float cur1RndPositionZ;
	private float rnd1RotationX;
	private float rnd1RotationY;
	private float rnd1RotationZ;
	
	void Start () 
	{
		for (int i = 0; i<=Asteroid1Count; i++)
		{
			//position
		cur1RndPositionX = Random.Range(-rndPositionX, rndPositionX);
		cur1RndPositionY = Random.Range(-rndPositionY, rndPositionY);
		cur1RndPositionZ = Random.Range(-rndPositionZ, rndPositionZ);
		Vector3 position = new Vector3 (cur1RndPositionX+transform.position.x,cur1RndPositionY+transform.position.y,cur1RndPositionZ+transform.position.z);
			//rotation
		rnd1RotationX = Random.Range(0,360);
		rnd1RotationY = Random.Range(0,360);
		rnd1RotationZ = Random.Range(0,360);
		Quaternion rotation = new Quaternion (rnd1RotationX,rnd1RotationY,rnd1RotationZ,rnd1RotationX);
			//scale
		_1scale = Random.Range(Asteroid1MinScale,Asteroid1MaxScale);
		Asteroid1CurScale =new Vector3(_1scale,_1scale,_1scale);
		Asteroid1.localScale = Asteroid1CurScale;
			
    	Transform go = Instantiate(Asteroid1, position, rotation) as Transform;
		go.parent = transform;
		}

	}
}

Оставить комментарий