- Home /
Creating multiple unique instances of one script
I have two different scripts (Enemy and EnemyShoot) attached to the same Game Object. Through this Enemy script. I'd like to create multiple unique instances of EnemyShoot script.
public class Enemy : MonoBehaviour
{
private EnemyShoot shoot;
void Start()
{
shoot = GetComponent<EnemyShoot>();
}
void Update()
{
float angle = shoot.AngleTowardsPlayer();
shoot.Spread(5, 10, angle, 2f, 3f, 3f, 0f);
shoot.Spread(1, 5, angle, 0.6f, 10f, 1f, 0f); //I'd like to use another unique instance of EnemyShoot for this line
}
The reason being, EnemyShoot script has a fireRateTimer which only allows the Spread() method to run when its <= 0. This affects the second call for Spread() since they use the same fireRateTimer eventhough I dont want them to use the same one. Any way to work around this?
Your answer
![](https://koobas.hobune.stream/wayback/20220612231402im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Help me with this code proplem,,Almost finish my game please help this once 3 Answers
Trying to find the highest number than add it to itself. 2 Answers
Activate/Deactivate Scripts form another Script 2 Answers
Save different game object's datas using the same script? 3 Answers
Character not jumping high enough 1 Answer