Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System.Numerics;
- using UnityEngine;
- public class SpawnScript : MonoBehaviour
- {
- public Rigidbody2D enemy;
- float randY;
- UnityEngine.Vector3 whereToSpawn;
- public float spawnRate = 2f;
- float nextSpawn = 0.0f;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- if (Time.time > nextSpawn)
- {
- nextSpawn = Time.time + spawnRate;
- Rigidbody2D clone;
- randY = Random.Range(-3f, 7.5f);
- whereToSpawn = new UnityEngine.Vector3(11, randY,-1);
- clone = Instantiate(enemy, whereToSpawn, transform.rotation);
- clone.velocity = transform.TransformDirection(UnityEngine.Vector3.forward * 10);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment