コード例 #1
0
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam) {
            return;
        }

        if(detected){
            ActionCam.ActionBullet (2.0f);
            ActionCam.ObjectLookAt = null;
            ActionCam.SlowmotionNow (0.1f, 1.6f);
            ActionCam.Follow = false;
            ActionCam.SetPosition (ActionCam.transform.position, ActionCam.Detected);
            ActionCam.ResetFOV();

        }else{

            // in case of missed prediction of hit point.
            // action camera will try to get new position as close as hit point

            ActionCam.FOVTarget = 20;
            ActionCam.ActionBullet (2.0f);
            ActionCam.ObjectLookAt = null;
            ActionCam.SlowmotionNow (0.1f, 1.6f);
            ActionCam.Follow = false;
            ActionCam.SetPosition (point - bullet.transform.forward * 5 * ZoomMulti, false);
            ActionCam.lookAtPosition = point;

        }

        base.TargetHited (bullet, target, point);
    }
コード例 #2
0
ファイル: AS_Bullet.cs プロジェクト: shahbazofficial/Sniper
    public void RunningDetectTarget()
    {
        // detection any object while a bullet is running
        RaycastHit[] camerahits;
        camerahits = Physics.RaycastAll(transform.position, transform.forward, RunningRaylength);

        for (var i = 0; i < camerahits.Length; i++)
        {
            RaycastHit hitcam = camerahits [i];
            if (hitcam.collider)
            {
                if (tagCheck(hitcam.collider.tag) && hitcam.collider.gameObject != this.gameObject)
                {
                    AS_BulletHiter bulletHit = hitcam.collider.gameObject.GetComponent <AS_BulletHiter> ();
                    if (bulletHit != null && bulletHit.HasAction)
                    {
                        if (actionPreset && !firsthited && !targetdetected)
                        {
                            actionPreset.BaseDistance = bulletHit.BaseActionDistance;
                            actionPreset.TargetDetected(this, bulletHit, hitcam.point);
                            targetdetected = true;
                            targetLocked   = null;
                        }
                    }
                }
            }
        }
    }
コード例 #3
0
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }


        if (detected)
        {
            ActionCam.ActionBullet(2.0f);
            ActionCam.ObjectLookAt = null;
            ActionCam.SlowmotionNow(0.1f, 1.6f);
            ActionCam.Follow = false;
            ActionCam.SetPosition(ActionCam.transform.position, ActionCam.Detected);
            ActionCam.ResetFOV();
        }
        else
        {
            // in case of missed prediction of hit point.
            // action camera will try to get new position as close as hit point

            ActionCam.FOVTarget = 20;
            ActionCam.ActionBullet(2.0f);
            ActionCam.ObjectLookAt = null;
            ActionCam.SlowmotionNow(0.1f, 1.6f);
            ActionCam.Follow = false;
            ActionCam.SetPosition(point - bullet.transform.forward * 5 * ZoomMulti, false);
            ActionCam.lookAtPosition = point;
        }

        base.TargetHited(bullet, target, point);
    }
コード例 #4
0
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        if (ActionCam.Detected)
        {
            ActionCam.ObjectLookAt = null;
            ActionCam.ActionBullet(3.0f);
            ActionCam.Follow = false;
        }
        else
        {
            ActionCam.ActionBullet(2.0f);
            ActionCam.ObjectLookAt = null;
            ActionCam.SlowmotionNow(0.1f, 1.6f);
            ActionCam.Follow         = false;
            ActionCam.lookAtPosition = point;
            ActionCam.SetPositionDistance(point, true);
        }

        base.TargetHited(bullet, target, point);
    }
コード例 #5
0
ファイル: AS_Bullet.cs プロジェクト: shahbazofficial/Sniper
    bool RayPrediction(Vector3 lastpos, Vector3 currentpos, Vector3 initialPosition, float delta)
    {
        // ray casting with a line of prediction
        RaycastHit[] hits;
        Vector3      dir = (currentpos - lastpos);

        dir.Normalize();

        hits = Physics.RaycastAll(lastpos, dir, 100);

        for (var i = 0; i < hits.Length; i++)
        {
            RaycastHit     hit       = hits [i];
            AS_BulletHiter bulletHit = hit.collider.gameObject.GetComponent <AS_BulletHiter> ();
            if (bulletHit != null && bulletHit.HasAction)
            {
                targetLocked       = bulletHit.gameObject;
                targetLockedOffset = hit.point - bulletHit.gameObject.transform.position;
                if (actionPreset && !firsthited)
                {
                    actionPreset.BaseDistance = bulletHit.BaseActionDistance;
                    actionPreset.FirstDetected(this, bulletHit, hit.point);
                    return(true);
                }
            }
            else if (hit.collider.gameObject.GetComponent <IDamagable>() != null)
            {
                Debug.LogError("HITT DAMAGABLE");
                hit.collider.gameObject.GetComponent <IDamagable>().ReciveDamage(Damage);

                return(true);
            }
        }
        return(false);
    }
コード例 #6
0
ファイル: AS_Bullet.cs プロジェクト: yantian001/3DHunter
    public void RunningDetectTarget()
    {
        RaycastHit[] camerahits;
        camerahits = Physics.RaycastAll(transform.position, transform.forward, RunningRaylength);

        for (var i = 0; i < camerahits.Length; i++)
        {
            RaycastHit hitcam = camerahits[i];
            if (hitcam.collider)
            {
                if (tagCheck(hitcam.collider.tag) && hitcam.collider.tag != this.gameObject.tag)
                {
                    if (hitcam.collider.GetComponent <AS_BulletHiter>())
                    {
                        AS_BulletHiter bulletHit = hitcam.collider.gameObject.GetComponent <AS_BulletHiter>();
                        if (actionPreset && !firsthited && !targetdetected)
                        {
                            actionPreset.TargetDetected(this, bulletHit, hitcam.point);
                            targetdetected = true;
                        }
                    }
                }
            }
        }
    }
コード例 #7
0
ファイル: AS_Bullet.cs プロジェクト: shahbazofficial/Sniper
 public void FirstDetectTarget()
 {
     // detect first object at start
     RaycastHit[] camerahits;
     camerahits = Physics.RaycastAll(transform.position, transform.forward, DetectorLength);
     for (var i = 0; i < camerahits.Length; i++)
     {
         RaycastHit hitcam = camerahits [i];
         if (hitcam.collider)
         {
             if (tagCheck(hitcam.collider.tag) && hitcam.collider.gameObject != this.gameObject)
             {
                 AS_BulletHiter bulletHit = hitcam.collider.gameObject.GetComponent <AS_BulletHiter> ();
                 if (bulletHit != null && bulletHit.HasAction)
                 {
                     if (actionPreset && !firsthited)
                     {
                         actionPreset.BaseDistance = bulletHit.BaseActionDistance;
                         actionPreset.FirstDetected(this, bulletHit, hitcam.point);
                     }
                 }
             }
         }
     }
 }
コード例 #8
0
    bool RayPrediction(Vector3 lastpos, Vector3 currentpos, Vector3 initialPosition, float delta)
    {
        // ray casting with a line of prediction
        RaycastHit[] hits;
        Vector3      dir = (currentpos - lastpos);

        dir.Normalize();

        hits = Physics.RaycastAll(lastpos, dir, 1);

        for (var i = 0; i < hits.Length; i++)
        {
            RaycastHit     hit       = hits [i];
            AS_BulletHiter bulletHit = hit.collider.gameObject.GetComponent <AS_BulletHiter> ();
            if (bulletHit)
            {
                targetLocked       = bulletHit.gameObject;
                targetLockedOffset = hit.point - bulletHit.gameObject.transform.position;
                if (actionPreset && !firsthited)
                {
                    actionPreset.FirstDetected(this, bulletHit, hit.point);
                    return(true);
                }
            }
        }
        return(false);
    }
コード例 #9
0
ファイル: AP_Slowmotion.cs プロジェクト: hydrater/Sniper
    public override void TargetDetected(AS_Bullet bullet, AS_BulletHiter target,Vector3 point)
    {
        if (!ActionCam) {
            return;
        }

        base.TargetDetected (bullet, target, point);
    }
コード例 #10
0
 public override void TargetDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam)
     {
         return;
     }
     base.TargetDetected(bullet, target, point);
 }
コード例 #11
0
ファイル: AS_ActionPreset.cs プロジェクト: hydrater/Sniper
 // When bullet start and detected a target on the way.
 public virtual void FirstDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam) {
         return;
     }
     ActionCam.Detected = true;
     ActionCam.ObjectLookAtRoot = target.RootObject;
     //Debug.Log("State : FirstDetected");
 }
コード例 #12
0
 // When bullet start and detected a target on the way.
 public virtual void FirstDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam)
     {
         return;
     }
     ActionCam.Detected         = true;
     ActionCam.ObjectLookAtRoot = target.RootObject;
     //Debug.Log("State : FirstDetected");
 }
コード例 #13
0
ファイル: AS_ActionPreset.cs プロジェクト: hydrater/Sniper
 // When bullet flying and detected a target on the way.
 public virtual void TargetDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam) {
         return;
     }
     //Debug.Log ("Running Detect target : " + target.name + " > "+ActionCam.Detected + " time "+Time.time);
     ActionCam.Detected = true;
     ActionCam.ObjectLookAtRoot = target.RootObject;
     //Debug.Log("State : TargetDetected");
 }
コード例 #14
0
ファイル: AP_Slowmotion.cs プロジェクト: hydrater/Sniper
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target,Vector3 point)
    {
        if (!ActionCam) {
            return;
        }

        ActionCam.ClearTarget();
        ActionCam.ResetFOV();
        base.TargetHited (bullet, target, point);
    }
コード例 #15
0
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        ActionCam.SlowmotionNow(0.1f, 1);
        base.TargetHited(bullet, target, point);
    }
コード例 #16
0
ファイル: AP_FastHit.cs プロジェクト: hydrater/Sniper
    public override void FirstDetected(AS_Bullet bullet, AS_BulletHiter target,Vector3 point)
    {
        if (!ActionCam) {
            return;
        }
        if (!ActionCam.InAction) {
            ActionCam.Slowmotion (0.5f, 0.3f);
        }

        base.FirstDetected (bullet, target, point);
    }
コード例 #17
0
 public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam)
     {
         return;
     }
     if (!ActionCam.Detected)
     {
         ActionCam.SetPositionDistance(target.transform.position, false);
     }
 }
コード例 #18
0
 // When bullet flying and detected a target on the way.
 public virtual void TargetDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam)
     {
         return;
     }
     //Debug.Log ("Running Detect target : " + target.name + " > "+ActionCam.Detected + " time "+Time.time);
     ActionCam.Detected         = true;
     ActionCam.ObjectLookAtRoot = target.RootObject;
     //Debug.Log("State : TargetDetected");
 }
コード例 #19
0
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        ActionCam.ClearTarget();
        ActionCam.ResetFOV();
        base.TargetHited(bullet, target, point);
    }
コード例 #20
0
ファイル: AP_Slowmotion.cs プロジェクト: hydrater/Sniper
    public override void FirstDetected(AS_Bullet bullet, AS_BulletHiter target,Vector3 point)
    {
        if (!ActionCam) {
            return;
        }
        if (!ActionCam.InAction) {
            ActionCam.Follow = true;
            ActionCam.SetPosition (bullet.transform.position + (bullet.transform.right * ZoomMulti) - (bullet.transform.forward * 2 * ZoomMulti), false);
            ActionCam.Slowmotion (0.1f, 1.0f);
        }

        base.FirstDetected (bullet, target, point);
    }
コード例 #21
0
 // When bullet hit target
 public virtual void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam)
     {
         return;
     }
     //Debug.Log("Hit : "+target.name + " > "+ ActionCam.Detected +" time "+Time.time);
     ActionCam.BaseDistance = BaseDistance;
     ActionCam.HitTarget    = true;
     //ActionCam.ObjectLookAtRoot = target.RootObject;
     ActionCam.PositionHit = point;
     //Debug.Log("State : TargetHited");
 }
コード例 #22
0
 // When bullet start and detected a target on the way.
 public virtual void FirstDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam)
     {
         return;
     }
     ActionCam.BaseDistance        = BaseDistance;
     ActionCam.Detected            = true;
     ActionCam.ObjectLookAtRoot    = target.RootObject;
     ActionCam.TargetShouldHit     = target.gameObject;
     ActionCam.PositionFirstDetect = bullet.transform.position;
     //Debug.Log("State : FirstDetected");
 }
コード例 #23
0
ファイル: AP_FastHit.cs プロジェクト: hydrater/Sniper
 public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target,Vector3 point)
 {
     if (!ActionCam) {
         return;
     }
     if(!ActionCam.Detected){
         ActionCam.SetPositionDistance(target.transform.position,false);
     }
     ActionCam.ResetFOV();
     ActionCam.ObjectFollowing = null;
     ActionCam.Follow = false;
     ActionCam.ObjectLookAt = null;
     base.TargetHited (bullet, target, point);
 }
コード例 #24
0
ファイル: AP_FastHit.cs プロジェクト: hydrater/Sniper
    public override void TargetDetected(AS_Bullet bullet, AS_BulletHiter target,Vector3 point)
    {
        if (!ActionCam) {
            return;
        }

        ActionCam.ObjectLookAt = target.gameObject;
        ActionCam.Follow = false;
        ActionCam.Slowmotion (0.2f, 0.2f);
        ActionCam.SetPositionDistance(target.transform.position,false);
        ActionCam.ActionBullet (2.0f);
        Debug.Log(">>>"+ActionCam.ObjectLookAt);
        base.TargetDetected (bullet, target, point);
    }
コード例 #25
0
ファイル: AP_SlowHitPreset.cs プロジェクト: hydrater/Sniper
    public override void TargetDetected(AS_Bullet bullet, AS_BulletHiter target,Vector3 point)
    {
        if (!ActionCam) {
            return;
        }

        ActionCam.lookAtPosition = point;
        ActionCam.Follow = false;
        ActionCam.SlowmotionNow (0.02f, 3);
        ActionCam.SetPositionDistance(point,false);
        ActionCam.ActionBullet (3.0f);
        ActionCam.SetFOV(35,true);
        base.TargetDetected (bullet, target, point);
    }
コード例 #26
0
    public override void FirstDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }
        if (!ActionCam.InAction)
        {
            ActionCam.Slowmotion(0.5f, 1);
        }


        base.FirstDetected(bullet, target, point);
    }
コード例 #27
0
 // When bullet flying and detected a target on the way.
 public virtual void TargetDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam)
     {
         return;
     }
     //Debug.Log ("Running Detect target : " + target.name + " > "+ActionCam.Detected + " time "+Time.time);
     ActionCam.BaseDistance        = BaseDistance;
     ActionCam.Detected            = true;
     ActionCam.ObjectLookAtRoot    = target.RootObject;
     ActionCam.TargetShouldHit     = target.gameObject;
     ActionCam.PositionFirstDetect = bullet.transform.position;
     //Debug.Log("State : TargetDetected");
 }
コード例 #28
0
ファイル: AP_FastHit.cs プロジェクト: yantian001/3DHunter
 public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam)
     {
         return;
     }
     if (!ActionCam.Detected)
     {
         ActionCam.SetPositionDistance(target.transform.position, false);
     }
     ActionCam.ObjectFollowing = null;
     ActionCam.Follow          = false;
     ActionCam.ObjectLookAt    = null;
     base.TargetHited(bullet, target, point);
 }
コード例 #29
0
    public override void FirstDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }
        if (!ActionCam.InAction)
        {
            ActionCam.Follow = true;
            ActionCam.SetPosition(bullet.transform.position + (bullet.transform.right * ZoomMulti) - (bullet.transform.forward * 2 * ZoomMulti), false);
        }


        base.FirstDetected(bullet, target, point);
    }
コード例 #30
0
 public override void TargetDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam) {
         return;
     }
     if (!ActionCam.HitTarget) {
         ActionCam.Follow = true;
         ActionCam.ActionBullet (10.0f);
         ActionCam.Slowmotion (0.015f, 10f);
         ActionCam.LengthMult = 0.2f;
         ActionCam.SetPosition (bullet.transform.position + (bullet.transform.right * ZoomMulti) - (bullet.transform.forward * ZoomMulti), ActionCam.Detected);
         ActionCam.CameraOffset = Vector3.right;
     }
     base.TargetDetected (bullet, target, point);
 }
コード例 #31
0
    public override void TargetDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        ActionCam.lookAtPosition = point;
        ActionCam.Follow         = false;
        ActionCam.SlowmotionNow(0.02f, 3);
        ActionCam.SetPositionDistance(point, false);
        ActionCam.ActionBullet(10.0f);
        ActionCam.SetFOV(10, true, 0.1f);
        base.TargetDetected(bullet, target, point);
    }
コード例 #32
0
    public override void TargetDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        ActionCam.ObjectLookAt = target.gameObject;
        ActionCam.Follow       = false;
        ActionCam.Slowmotion(0.2f, 0.2f);
        ActionCam.SetPositionDistance(target.transform.position, false);
        ActionCam.ActionBullet(2.0f);
        Debug.Log(">>>" + ActionCam.ObjectLookAt);
        base.TargetDetected(bullet, target, point);
    }
コード例 #33
0
ファイル: AP_SlowHitPreset.cs プロジェクト: hydrater/Sniper
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target,Vector3 point)
    {
        if (!ActionCam) {
            return;
        }
        if(!ActionCam.Detected){
            ActionCam.SetPositionDistance(point,false);
        }
        ActionCam.ActionBullet (3.0f);
        ActionCam.SlowmotionNow (0.01f, 3);

        ActionCam.ObjectFollowing = null;
        ActionCam.Follow = false;
        ActionCam.ObjectLookAt = null;
        base.TargetHited (bullet, target, point);
    }
コード例 #34
0
 public override void TargetDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     if (!ActionCam)
     {
         return;
     }
     if (!ActionCam.HitTarget)
     {
         ActionCam.Follow = true;
         ActionCam.ActionBullet(10.0f);
         ActionCam.Slowmotion(0.015f, 10f);
         ActionCam.LengthMult = 0.2f;
         ActionCam.SetPosition(bullet.transform.position + (bullet.transform.right * ZoomMulti) - (bullet.transform.forward * ZoomMulti), ActionCam.Detected);
         ActionCam.CameraOffset = Vector3.right;
     }
     base.TargetDetected(bullet, target, point);
 }
コード例 #35
0
    public override void TargetDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        if (!ActionCam.HitTarget)
        {
            ActionCam.ObjectLookAt = bullet.gameObject;
            ActionCam.Follow       = true;
            ActionCam.SlowmotionNow(0.02f, 3.0f);
            ActionCam.SetPosition(point + (target.transform.right * ActionCam.Length), false);
            ActionCam.ActionBullet(10.0f);
        }
        base.TargetDetected(bullet, target, point);
    }
コード例 #36
0
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        ActionCam.ActionBullet(3.0f);
        ActionCam.ObjectLookAt = null;
        ActionCam.SlowmotionNow(0.02f, 1.0f);
        ActionCam.Follow         = true;
        ActionCam.lookAtPosition = point;
        ActionCam.SetPosition(point + (target.transform.right * ZoomMulti) - (target.transform.forward * 2 * ZoomMulti), true);
        ActionCam.LengthMult = 0.5f;

        base.TargetHited(bullet, target, point);
    }
コード例 #37
0
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }
        if (!ActionCam.Detected)
        {
            ActionCam.SetPositionDistance(point, false);
        }
        ActionCam.ActionBullet(3.0f);
        ActionCam.SlowmotionNow(0.01f, 3);

        ActionCam.ObjectFollowing = null;
        ActionCam.Follow          = false;
        ActionCam.ObjectLookAt    = null;
        base.TargetHited(bullet, target, point);
    }
コード例 #38
0
    public override void TargetHited(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        ActionCam.SetPositionDistance(point, true);
        ActionCam.lookAtPosition = point;
        ActionCam.ActionBullet(2.0f);
        ActionCam.SlowmotionNow(0.03f, 1);
        ActionCam.SetFOV(20, true, 0.1f);
        ActionCam.ObjectFollowing = null;
        ActionCam.Follow          = true;
        ActionCam.SetPosition(point - bullet.transform.forward * 5, false);

        base.TargetHited(bullet, target, point);
    }
コード例 #39
0
    public override void FirstDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam) {
            return;
        }

        if (!ActionCam.InAction) {
            ActionCam.ObjectLookAt = bullet.gameObject;
            ActionCam.Follow = true;
            ActionCam.ActionBullet (10.0f);
            ActionCam.SlowmotionNow (0.5f, 3.0f);
            ActionCam.LengthMult = 0.2f;
            ActionCam.SetPosition (bullet.transform.position + (bullet.transform.right * ZoomMulti) - (bullet.transform.forward * ZoomMulti), ActionCam.Detected);
            ActionCam.CameraOffset = -Vector3.right;
            detected = true;

        }

        base.FirstDetected (bullet, target, point);
    }
コード例 #40
0
    public override void FirstDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        if (!ActionCam.InAction)
        {
            ActionCam.ObjectLookAt = bullet.gameObject;
            ActionCam.Follow       = true;
            ActionCam.ActionBullet(10.0f);
            ActionCam.SlowmotionNow(0.025f, 3.0f);
            ActionCam.LengthMult = 0.2f;
            ActionCam.SetPosition(bullet.transform.position + (bullet.transform.right * ZoomMulti) - (bullet.transform.forward * ZoomMulti), ActionCam.Detected);
            ActionCam.CameraOffset = -Vector3.right;
        }


        base.FirstDetected(bullet, target, point);
    }
コード例 #41
0
    public override void FirstDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
    {
        if (!ActionCam)
        {
            return;
        }

        if (!ActionCam.InAction)
        {
            ActionCam.ObjectLookAt = bullet.gameObject;
            ActionCam.Follow       = true;
            ActionCam.ActionBullet(10.0f);
            //This is the method you wanna change when bullet is on it's path!
            ActionCam.SlowmotionNow(0.1f, 3.0f);
            ActionCam.LengthMult = 0.1f;
            ActionCam.SetPosition(bullet.transform.position + (bullet.transform.right) - (bullet.transform.forward), ActionCam.Detected);
            ActionCam.CameraOffset = ((bullet.transform.right) - (bullet.transform.forward)) * 0.2f;
            detected = true;
        }


        base.FirstDetected(bullet, target, point);
    }
コード例 #42
0
 public override void FirstDetected(AS_Bullet bullet, AS_BulletHiter target, Vector3 point)
 {
     base.FirstDetected(bullet, target, point);
 }
コード例 #43
0
ファイル: AS_Bullet.cs プロジェクト: shahbazofficial/Sniper
    public bool RayShoot(bool first)
    {
        bool res = false;

        RaycastHit[]   hits;
        List <casthit> castHits = new List <casthit> ();

        // calculate ray length by running magnitude.
        float   raySize   = runningmMagnitude;
        Vector3 direction = rigidBodyComp.velocity.normalized;

        if (first)
        {
            raySize   = FirstRaylength;
            direction = initialDirection;
        }

        if (raySize <= 2.0f)
        {
            raySize = 2.0f;
        }

        Vector3 pos1 = this.transform.position - (direction * raySize);

        //Vector3 pos2 = pos1 + (direction * raySize);

        if (first)
        {
            pos1 = initialPosition;
            //pos2 = pos1 + (direction * raySize);
        }

        // if you add line renderer. you can see how the ray is casting
        if (lineRenderer)
        {
            LineRenderer line = (LineRenderer)GameObject.Instantiate(lineRenderer, pos1, Quaternion.identity);
            line.SetPosition(0, pos1);
            line.SetPosition(1, pos1 + (raySize * direction));
            line.name = "laser " + raySize + " direction " + direction;
            GameObject.Destroy(line, 10);
        }


        // shoot ray to casting all objects
        int castcount = 0;

        RaycastHit[] casterhits = Physics.RaycastAll(pos1, direction, raySize, ignoreWalkThru);
        for (int i = 0; i < casterhits.Length; i++)
        {
            if (casterhits [i].collider && Vector3.Dot((casterhits [i].point - initialPosition).normalized, initialDirection) > 0.5f)
            {
                // checking a target tags. make sure it hit only taged object.
                if (tagCheck(casterhits [i].collider.tag) && casterhits [i].collider.gameObject != this.gameObject)
                {
                    // checking for make sure it not hit the same object 2 time.
                    if (hitedCheck(casterhits [i].collider))
                    {
                        castcount++;
                        casthit casted = new casthit();
                        casted.distance = Vector3.Distance(initialPosition, casterhits [i].point);
                        casted.index    = i;
                        casted.name     = casterhits [i].collider.name;
                        castHits.Add(casted);
                    }
                }
            }
        }

        // and sorted first to the last by distance
        hits = new RaycastHit[castcount];
        castHits.Sort((x, y) => x.distance.CompareTo(y.distance));

        for (int i = 0; i < castHits.Count; i++)
        {
            hits [i] = casterhits [castHits [i].index];
        }

        for (var i = 0; i < hits.Length && hitcount < HitCountMax; i++)
        {
            RaycastHit hit = hits [i];

            if (first)
            {
                firsthited = true;
            }
            else
            {
                hited = true;
            }

            targetLocked = null;

            Rigidbody hitrig = hit.collider.GetComponent <Rigidbody> ();
            if (hitrig)
            {
                hitrig.AddForce(direction * HitForce * Time.deltaTime, ForceMode.Force);
            }

            // get bullet hiter component.
            AS_BulletHiter bulletHit = hit.collider.gameObject.GetComponent <AS_BulletHiter> ();

            if (bulletHit != null)
            {
                // using action preset
                if (actionPreset && !firsthited && bulletHit.HasAction)
                {
                    actionPreset.BaseDistance = bulletHit.BaseActionDistance;
                    actionPreset.TargetHited(this, bulletHit, hit.point);
                }
                // get particle life time from hiter
                bulletHit.OnHit(hit, this);
            }

            // call do damage function on an object that's got hit.
            hit.collider.SendMessageUpwards(DamageMethodName, (float)Damage, SendMessageOptions.DontRequireReceiver);
            this.SendMessageUpwards(DoHitMethodName, SendMessageOptions.DontRequireReceiver);
            // check a hit number if bullet is still hit under max count.
            res = true;
            hitcount++;
            if (DestroyWhenHit || hitcount >= HitCountMax || tagDestroyerCheck(hit.collider.tag))
            {
                destroyed = true;
            }
        }
        if (destroyed)
        {
            if (actionPreset)
            {
                // using action preset
                actionPreset.OnBulletDestroy();
            }
            // completely removed
            GameObject.Destroy(this.gameObject, DestroyDuration);
        }

        return(res);
    }