// Update is called once per frame void Update() { bool success; //Debug.Log("enemy laser from Update:" + xProjectile); CountDownAndShoot(); if (Player == null || !Player.activeSelf) { agent.setEnemyActive(1, thisEnemyIndex, false); /* turn enemy to active*/ Destroy(gameObject); // I'm going to destroy all enemies if the player dies disappears! } if (thisEnemyIndex >= 0) { Vector3 thisPos = transform.position; Vector2 TwoPos; TwoPos.x = thisPos.x; TwoPos.y = thisPos.y; success = agent.setEnemyPosition(1, thisEnemyIndex, TwoPos); if (!success) { Destroy(gameObject); } } }
// Update is called once per frame void Update() { if (Player == null || !Player.activeSelf || agent == null) { agent.setEnemyActive(EnemyOrPlayer, thisEnemyLaserIndex, false); /* turn enemy to active*/ Destroy(gameObject); // I'm going to destroy all enemies if the player dies disappears! } if (thisEnemyLaserIndex >= 0) { Vector3 thisPos = transform.position; Vector3 copyPos = transform.position; bool success; Vector2 TwoPos; TwoPos.x = thisPos.x; TwoPos.y = thisPos.y; TwoPos.y -= Time.deltaTime * laserSpeed; copyPos.x = TwoPos.x; copyPos.y = TwoPos.y; transform.position = copyPos; success = agent.setEnemyPosition(EnemyOrPlayer, thisEnemyLaserIndex, TwoPos); if (!success) { Destroy(gameObject); } // Debug.Log("laserindex:"+ thisEnemyLaserIndex+" enemylaser positon:" + TwoPos); } }