void Update () { if (Input.GetKeyDown(KeyCode.Alpha1)) { isInBulletHoleMode = false; } else if(Input.GetKeyDown(KeyCode.Alpha2)) { isInBulletHoleMode = true; } if (Input.GetMouseButtonDown(0)) { if (isInBulletHoleMode) { GameObject newBullet = GameObject.Instantiate(bulletPfb); newBullet.gameObject.SetActive(true); newBullet.transform.position = newBulletPosition.transform.position; newBullet.transform.rotation = newBulletPosition.transform.rotation; newBullet.GetComponent().AddRelativeForce(new Vector3(0f, 0f, 50f), ForceMode.Impulse); } else { Ray ray = Camera.main.ViewportPointToRay(Vector2.one * 0.5f); RaycastHit hit; if (Physics.Raycast(ray, out hit, 50f)) { Debug.Log("hit : " + hit.collider.name); GameObject newBullet = GameObject.Instantiate(bulletHolePfb); newBullet.gameObject.SetActive(true); newBullet.transform.position = hit.point - newBullet.transform.forward * 0.5f; newBullet.transform.rotation = hit.collider.transform.rotation; } } } if(Input.GetKeyDown(KeyCode.LeftShift)) { Time.timeScale = 0.2f; Time.fixedDeltaTime = 0.005f; } if(Input.GetKeyUp(KeyCode.LeftShift)) { Time.timeScale = 1f; Time.fixedDeltaTime = 0.02f; } }