Guest User

Untitled

a guest
Jun 18th, 2020
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Numerics;
  4. using UnityEngine;
  5.  
  6. public class SpawnScript : MonoBehaviour
  7. {
  8. public Rigidbody2D enemy;
  9. float randY;
  10. UnityEngine.Vector3 whereToSpawn;
  11. public float spawnRate = 2f;
  12. float nextSpawn = 0.0f;
  13.  
  14.  
  15.  
  16.  
  17.  
  18. // Start is called before the first frame update
  19. void Start()
  20. {
  21.  
  22. }
  23.  
  24. // Update is called once per frame
  25. void Update()
  26. {
  27. if (Time.time > nextSpawn)
  28. {
  29. nextSpawn = Time.time + spawnRate;
  30. Rigidbody2D clone;
  31. randY = Random.Range(-3f, 7.5f);
  32. whereToSpawn = new UnityEngine.Vector3(11, randY,-1);
  33. clone = Instantiate(enemy, whereToSpawn, transform.rotation);
  34. clone.velocity = transform.TransformDirection(UnityEngine.Vector3.forward * 10);
  35.  
  36. }
  37.  
  38.  
  39.  
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment