The script where I instantiate the clones:
if (postition == 1f)
{
Instantiate(enemy, pos1.transform.position, pos1.transform.rotation) ;
direction = 350;
}
if (postition == 2f)
{
Instantiate(enemy2, pos2.transform.position, pos2.transform.rotation) ;
direction = -350;
}
if (postition == 3f)
{
Instantiate(enemy2, pos3.transform.position, pos3.transform.rotation) ;
direction = -350;
}
if (postition == 4f)
{
Instantiate(enemy, pos4.transform.position, pos4.transform.rotation) ;
direction = 350;
}
enemyspawn = 1;
and the script where I try to delete the clones:
// Update is called once per frame
void Update()
{
rb.AddForce(new Vector2(400, 0) * Time.deltaTime);
}
public void destruction()
{
Debug.Log("hit");
Destroy(self);
}
}
the script to instantiate them is in a different gameobject than the one to destroy them.
I dont know if that makes a difference, I am new to unity.