Hello everyone,
I’m a fairly for fun/newbie unity user and recently I’ve been developing a space shooter for my phone inspired by the classic Space Invaders game.
I am creating a boss level and the mechanic is pretty simple after a timer passes the boss gets 2 extra helper ships in front of him and while they are alive he also gains a shield. So the player has to destroy them to get the shield off and do damage the boss.
Everything is working fine the minions spawn the boss’s shield instantiates at an empty child object I’ve placed in front of him and when I destroy the minions the shield disappears. The only problem is the shield will not play it’s default animation.
I have two codes that are responsible for all of this.
The spawner code:
public class secondBossShieldSpawn : MonoBehaviour
{
public GameObject enemyShield;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (GameObject.Find("Ship4small(Clone)") != null || GameObject.Find("Ship4small2(Clone)") != null && GameObject.Find("bossShield(Clone)") == null)
{
Instantiate(enemyShield, transform.position, transform.rotation);
}
}
}
Pretty simple basically it checks if one of the two minions exist and if there is another shield already spawned.
And the shield code itself:
public class bossShieldSelfDestruct : MonoBehaviour
{
public GameObject enemyBoss;
// Start is called before the first frame update
void Start()
{
enemyBoss = GameObject.Find("ShieldSpawn");
}
// Update is called once per frame
void Update()
{
gameObject.transform.position = enemyBoss.transform.position;
if (GameObject.Find("Ship4small") == null && GameObject.Find("Ship4small2") == null)
{
Destroy(gameObject);
}
}
}
Which should just follows the ship spawn position and when the minions are destroyed also destroys the shield itself.
I haven’t touched anything about the animator or the animation and even redid them a few times bit the problem persists no animation after instantiating the shield. The only setting that I changed is make the animation non-looping. If anyone has any ideas please share and if you need more info please ask!