Пример #1
0
        protected override void Hitscan()
        {
            // autoaim
            Vector3 aimedDir;

            Autoaim.Aim(AimTransform.position, AimTransform.forward, AimRadius, out aimedDir, Range, AutoaimLayerMask);

            float rangey = 1 - Accuracy;

            rangey *= MaxAngleY;

            float deltax = 2 * (1 - Accuracy) / pelletCount;
            float basex  = -(1 - Accuracy);

            if (HealthInt >= 3)
            {
                deltax *= MaxAngleX;
                basex  *= MaxAngleX;
            }
            else
            {
                deltax *= MaxAngleX / 3.0f;
                basex  *= MaxAngleX / 3.0f;
            }

            for (int i = 0; i < pelletCount; i++)
            {
                // process accuracy
                float rangexl = basex + deltax * i;
                float rangexr = basex + deltax * (i + 1);

                Vector3 distortedDir =
                    Quaternion.AngleAxis(Random.Range(rangexl, rangexr), AimTransform.up)
                    * Quaternion.AngleAxis(Random.Range(-rangey, rangey), AimTransform.right)
                    * aimedDir;

                CheckRay(AimTransform.position, distortedDir);

                //Vector3 end = CheckRay(AimTransform.position, distortedDir);

                //// emit trail, if muzzle flash transform exists
                //if (MuzzleFlash != null)
                //{
                //    EmitTrail(MuzzleFlash.position, end);
                //}
            }
        }
Пример #2
0
        protected override void Hitscan()
        {
            // autoaim
            Autoaim.Aim(AimTransform.position, AimTransform.forward, AimRadius, out Vector3 aimedDir, Range, AutoaimLayerMask);

            // process accuracy
            float rangex = (1 - Accuracy) * MaxAngleX;
            float rangey = (1 - Accuracy) * MaxAngleY;

            Vector3 distortedDir = HealthInt >= 3 ?
                                   Quaternion.AngleAxis(Random.Range(-rangex, rangex), AimTransform.up)
                                   * Quaternion.AngleAxis(Random.Range(-rangey, rangey), AimTransform.right)
                                   * aimedDir :
                                   aimedDir;

            Vector3 end = CheckRay(AimTransform.position, distortedDir);

            // emit trail, if muzzle flash transform exists
            if (MuzzleFlash != null)
            {
                EmitTrail(MuzzleFlash.position, distortedDir, end);
            }
        }