Ejemplo n.º 1
0
 private void Hit()
 {
     if (Physics.Raycast(thecam.transform.position, thecam.transform.forward +
                         new Vector3(Random.Range(-crossHair.GetAccuracy() - currentGun1.accuracy, crossHair.GetAccuracy() + currentGun1.accuracy),
                                     Random.Range(-crossHair.GetAccuracy() - currentGun1.accuracy, crossHair.GetAccuracy() + currentGun1.accuracy), 0)
                         , out hitInfo, currentGun1.range))
     {
         GameObject clone = Instantiate(hit_effect_1, hitInfo.point, Quaternion.LookRotation(hitInfo.normal));
         Destroy(clone, 0.2f);
     }
 }
Ejemplo n.º 2
0
 private void Hit() // 적중되는 위치
 {
     if (Physics.Raycast(theCam.transform.position,
                         theCam.transform.forward +
                         new Vector3(
                             Random.Range(-theCrossHair.GetAccuracy() - currentGun.accuracy, theCrossHair.GetAccuracy() - currentGun.accuracy),
                             Random.Range(-theCrossHair.GetAccuracy() - currentGun.accuracy, theCrossHair.GetAccuracy() - currentGun.accuracy), // Random.Range를 통해 반동 구현
                             0),                                                                                                                // 랜덤하게 수치 변화
                         out hitInfo,
                         currentGun.range,
                         theLayerMask))
     {
         //Debug.Log(hitInfo.transform.name);
         //Quaternion.LookRotation(hitInfo.normal) -> 위를 바라보는 곳으로 생성
         GameObject clone = Instantiate(hit_effect_prefab, hitInfo.point, Quaternion.LookRotation(hitInfo.normal));
         // 이해가 잘 되진 않은...
         // 메모리에 계속 쌓여 이걸 제거하는 함수 필요
         Destroy(clone, 2f); // 2초뒤에 clone을 파괴
     }
 }
Ejemplo n.º 3
0
    //총알을 맞출 때
    private void Hit()
    {
        ///**param
        ///origin, direction, out hitinfo, maxDistance, layerMask
        if (Physics.Raycast(theCam.transform.position
                            , theCam.transform.forward + new Vector3(Random.Range(-theCrosshair.GetAccuracy() - currentGun.accuracy
                                                                                  , theCrosshair.GetAccuracy() + currentGun.accuracy)
                                                                     , Random.Range(-theCrosshair.GetAccuracy() - currentGun.accuracy
                                                                                    , theCrosshair.GetAccuracy() + currentGun.accuracy)
                                                                     , 0)
                            , out hitInfo, currentGun.range, layerMask))
        {
            var Clone = Instantiate(hitEffect_Prefab, hitInfo.point, Quaternion.LookRotation(hitInfo.normal));
            Destroy(Clone, 2f); //2초후 클론 파괴
            Debug.Log(hitInfo.transform.name);

            if (hitInfo.transform.CompareTag("WeakAnimal") || hitInfo.transform.CompareTag("WeakAnimalSuper"))
            {
                hitInfo.transform.GetComponent <WeakAnimal>().Damage(currentGun.damage, transform.position);
            }
        }
    }
Ejemplo n.º 4
0
 /* 상태, 및 총에 따른 정확도 랜덤 계산 함수 */
 private float createRandomAccuracy()
 {
     return(Random.Range(
                -theCrossHair.GetAccuracy(isFineSightMode) - currentGun.accuracy,
                theCrossHair.GetAccuracy(isFineSightMode) + currentGun.accuracy));
 }