public void TryToFire( ) { if (spawnPoint == null) { return; } if (realoadTimeLeft > 0 || timeToNextShot > 0) { return; } audioEvent.Raise(AudioEvents.RocketLaunch, transform.position); GameObject missile = Instantiate(parameters.Projectile, spawnPoint.position, Quaternion.Euler(0, 0, 90 + Random.Range(-15f, 15f))); hasShotMissile = true; if (mechAnimScript != null) { mechAnimScript.positionLocked = true; } HomingMissile missileScript = missile.GetComponent <HomingMissile>(); missileScript.fromTeam = FromTeam; //Debug.Log("Has shot missile Launcher CS " + hasShotMissile); missileScript.SetDamage(parameters.GetDamage( )); //let homingMissile script know mech that shot. Used so self-circle collider of wing spawn is ignored for collision //currently console returns error because the below hierarchy fits the winged spawn only. TODO //Transform shootingMech = transform.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent.parent; //Debug.Log("Mech Shooting" + shootingMech); //missile.GetComponent<HomingMissile>().ReceiveMechName(shootingMech); //find parent mech object that shot and pass it to homing Missile so missile ignores hitting that mech at first shootingMech = FindParentWithTag(transform, "Mech"); Debug.Log("Name of Shooting Mech IS " + shootingMech.name); missileScript.ReceiveMechName(shootingMech); // TODO: suggest that we compare TAGS, not which gamepad this player is controlled by missileScript.playerNumber = transform.GetComponentInParent <Mech>().driver.gamepadNumber; // FIXME if (cursor == null) { cursor = UIResourceManager.MouseCursor; } cursor.AddMissile(missile); missile.transform.SetParent(LitterContainer.instanceTransform); timeToNextShot = parameters.DelayBetweenShots; currentMagSize--; if (isPlayerDriver) { weaponSlotEvents.Raise(UIEvent.LauncherOn, currentMagSize / parameters.MagSize); } if (currentMagSize <= 0) { currentMagSize = (int)parameters.MagSize; realoadTimeLeft = parameters.RealoadTime; } }