Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

How do I create bullet hole for my gun?

$
0
0
I want to create a gun I followed a tutorial but my Bullet holes are not in the correct position GameObject bulletHole = Instantiate(bulletHole, hit.point + (hit.normal * .1f), Quaternion.FromToRotation(Vector3.forward, hit.normal)); my entire script void Update() { if (allowButtonHold) { shooting = Input.GetKey(KeyCode.Mouse0); } else { shooting = Input.GetKeyDown(KeyCode.Mouse0); } if (Input.GetKeyDown(KeyCode.R) && bulletsLeft < magazineSize && !reloading) Reload(); if (bulletsLeft <= 0) { Reload(); } if (readyToShoot && shooting && !reloading && bulletsLeft > 0) { bulletsShot = bulletPerTap; Shoot(); } } private void Reload() { reloading = true; Invoke("ReloadFinished", reloadTime); } private void ReloadFinished() { bulletsLeft = magazineSize; reloading = false; } private void Shoot() { //readyToShoot = false; Debug.Log(bulletsLeft); float x = Random.Range(-spread, spread); float y = Random.Range(-spread, spread); Vector3 direction = camera.transform.forward + new Vector3(x,y,0); if (Physics.Raycast(camera.transform.position, direction, out hit, range)) { Debug.Log(hit.collider.name); } GameObject bulletHole = Instantiate(bulletHole, hit.point + (hit.normal * .1f), Quaternion.FromToRotation(Vector3.forward, hit.normal)); bulletsLeft--; bulletsShot--; Invoke("ResetShot()", timeBetweenShooting); if (bulletsShot > 0 && bulletsLeft > 0) Invoke("Shoot()", timeBetweenShots); } private void ResetShot() { readyToShoot = true; } thanks

Viewing all articles
Browse latest Browse all 592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>