void Start () { if (CheckErrors() == true) { return; } turretScript = GetComponent<ST_Turret>(); if ( GetComponent<MF_AbstractTargeting>() ) { targetingScript = GetComponent<MF_AbstractTargeting>(); } // cache scripts for all weapons if ( weapons.Length > 0 ) { for (int wd=0; wd < weapons.Length; wd++) { if (weapons[wd].weapon) { weapons[wd].script = weapons[wd].weapon.GetComponent<MF_BasicWeapon>(); } } //set fixed converge angle of weapons relative to weaponMount forward direction, to converge at given range. 0 = no fixed convergence if (fixedConvergeRange > 0) { for (int w=0; w < weapons.Length; w++) { if (weapons[w].weapon) { weapons[w].weapon.transform.rotation = Quaternion.LookRotation( turretScript.weaponMount.transform.position + ( turretScript.weaponMount.transform.forward * fixedConvergeRange ) - weapons[w].weapon.transform.position, turretScript.weaponMount.transform.up ); } } } } }
void setRange() { scanner.detectorRange = rowData._Range; turret = this.GetComponent<ST_Turret>(); if(turret!=null) { turret.rotationRateMax = rowData._RotationRateMax; turret.elevationRateMax = rowData._ElevationRateMax; turret.rotationAccel = rowData._RotationAccel; turret.elevationRateMax = rowData._ElevationRateMax; turret.elevationAccel = rowData._ElevationAccel; } }
public override void Start() { base.Start(); if (error == true) { return; } turretScript = GetComponent <ST_Turret>(); // cache scripts for all weapons if (weapons.Length > 0) { for (int wd = 0; wd < weapons.Length; wd++) { if (weapons[wd].weapon) { weapons[wd].script = weapons[wd].weapon.GetComponent <MF_AbstractWeapon>(); } } //set fixed converge angle of weapons relative to weaponMount forward direction, to converge at given range. 0 = no fixed convergence if (fixedConvergeRange > 0) { for (int w = 0; w < weapons.Length; w++) { if (weapons[w].weapon) { weapons[w].weapon.transform.rotation = Quaternion.LookRotation(turretScript.weaponMount.transform.position + (turretScript.weaponMount.transform.forward * fixedConvergeRange) - weapons[w].weapon.transform.position, turretScript.weaponMount.transform.up); } } } } loaded = true; OnValidate(); }