Esempio n. 1
0
    public IEnumerator Track()      //movement
    {
        looking = true;
        while (enTran)
        {
            line2En   = Vector3.Normalize(enTran.position - barrelTran.position);
            line2Tip  = Vector3.Normalize(tipTran.position - barrelTran.position);
            ang2En    = Vector3.Angle(zeroLine, line2En);
            angTip2En = Vector3.Angle(line2Tip, line2En);
            targetAng = -ang2En;             //totally works
            gunScale  = turretGun.transform.localScale;
            turretGun.transform.rotation = Quaternion.Euler(0f, 0f, quantizeAnglesScript.FullTrackJacket(targetAng));
            rotationZ = turretGun.transform.rotation.eulerAngles.z;

            if ((rotationZ < 270f && rotationZ >= 90f) || (rotationZ < -90f && rotationZ > -270f))
            {
                turretGun.transform.localScale = new Vector3(gunScale.x, -1f, gunScale.z);
            }
            else if ((rotationZ >= 270f && rotationZ <= 360f) || (rotationZ > -90f && rotationZ <= 90f))
            {
                turretGun.transform.localScale = new Vector3(gunScale.x, 1f, gunScale.z);;
            }
            yield return(null);
        }
    }