Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- public class EnemyFireProjectileBase : MonoBehaviour
- {
- [Header("Projectile settings")]
- [field: SerializeField] public GameObject[] m_projectiles {get; private set;} //Projectiles are pre created to save on performance
- [field: SerializeField] public float m_speed { get; private set; } //Speed of projectile
- [Header("Fire settings")]
- [field: SerializeField] public float m_firingInterval { get; private set; } //Firing interval between bullets
- [field: SerializeField] public float m_cooldown { get; private set; } //Cooldown between volley
- public Rigidbody2D m_rb { get; private set; }
- public List<Rigidbody2D> m_rbList { get; private set; }
- public Transform m_player { get; private set; }
- // Start is called once before the first execution of Update after the MonoBehaviour is created
- void Start()
- {
- m_rb = GetComponent<Rigidbody2D>();
- m_player = GameObject.FindGameObjectWithTag("Player").transform;
- m_rbList = new List<Rigidbody2D>();
- for (int i = 0; i < m_projectiles.Length; i++)
- {
- m_rbList.Add(m_projectiles[i].GetComponent<Rigidbody2D>());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment