Results are as follows:
Expected effect, in the launch of the barrage of each round, all the distance between the barrage should be equal to
Because too many objects, as a result of system running slow? (already set up the map border, the barrage of collision to the border of the map will be destroyed)
If this is how should solve?
Attached to the BOSS's launch code:
reference o IEnumerator a non empty (int boshu)//scattering play { Cooltime=4 f; Yield return new WaitForSeconds (0.1 f);//0.1 s per wave delay launch Vector3 bulletDir=new Vector3 (0, 1, 0);//the first shot fired direction Vector2 position=rigidbody2d. Position;//launch site Float angle2=Random. Range (3, 3 f).//random play, micro Angle offset Quaternion rotateQuate2=Quaternion. AngleAxis (angle2, Vector3. Forward);//using quaternions to make random play offset BulletDir=rotateQuate2 * bulletDir; Int Angle=6; Quaternion RightRota=Quaternion. AngleAxis (Angle, Vector3. Forward);//using quaternions to make the rotation of the rotating every fixed for (int i=0; i { For (int j=0; J & lt; (360/Angle); J++)//a 60 direction of bullets { CreatBullet (bulletDir, position, 100, j * 6 f);//instantiate the bullets, numerical toward respectively, position, power, rotation Angle BulletDir=RightRota * bulletDir; } Yield return new WaitForSeconds (0.02 f);//coroutines delay time of 0.02 seconds for the next wave of launch, namely each string in the barrage of the distance between every two bolts, in theory, every two bolts is approximately 0.02 s launch, spacing should be equal to } } Instantiation code: Void CreatBullet (Vector3 vector, Vector2 position, int force, float j)//generated barrage { GameObject projectileObject=Instantiate (danmu1o1, position, Quaternion. Identity); Danmu1o1 projectile=projectileObject. GetComponent Projectile. Launch (vector of the force, j); } Attached to the launch photoelastic code: //Start is called before the first frame update Rigidbody2D Rigidbody2D; Public float barrage size=2.5 f; Void Awake () { Rigidbody2d=GetComponent Transform. LocalScale=new Vector3 (barrage size, the barrage size, barrage size);//set the barrage size } Void the Start () { } Public void Launch (Vector2 direction, float force, float j) { Rigidbody2d. AddForce (direction * force); This. The transform. The Rotate (0, 0, j, Space. The Self).//rotate StartCoroutine (jiasu (direction, force));//launch acceleration after 0.5 s } Void OnTriggerEnter2D Collider2D (other) { If (other) tag=="LevelObjects3")//see the tag { Destroy (gameObject);//the wall destruction }//* * F1=other Player control. GetComponent If (f1!=null) { F1. Playerhpdamage (1); If (f1) isInvincible==false) Destroy (gameObject);//hit our } } IEnumerator jiasu (Vector2 d, float f)//acceleration, the problem and speed up it doesn't matter, also has closed the acceleration seam,,,, { Yield return new WaitForSeconds (0.5 f); Rigidbody2d. AddForce (d * 400 f); }