- Home /
Sniper bullets not working
So, when I fire my sniper bullets they don't hit the targets that they're supposed to unless you're standing very close to the target. And if I increase the fly power it still doesn't hit the targets that are far away or the ones that are close. So how do I make it so that the bullets go where they are supposed to go? And it isn't a problem with the bullet spawn.
My sniper script:
function Shoot () {
audio.Play();
CockingSound.audio.Play();
var BulletPrefab : Rigidbody;
BulletPrefab = Instantiate(Bullet, BarrelEnd.position, BarrelEnd.rotation);
BulletPrefab.AddForce(BarrelEnd.forward * 10000);
animation.Play("ShootM40A5");
MuzzleLight.enabled = true;
MuzzleImg.renderer.enabled = true;
yield WaitForSeconds(0.1);
MuzzleLight.enabled = false;
MuzzleImg.renderer.enabled = false;
AmmoInCurrentMag -= 1;
CanShoot = false;
yield WaitForSeconds(0.5);
CanShoot = true;
}
BulletPrefab.AddForce(BarrelEnd.forward * 10000);
Your bullets are either too tiny or too fast, suggest changing the whatever you are shooting at to mesh colliders or make the colliders on the targe a bit thicker.
Are your targets in motion? You may want to just simulate a bullet fly out ins$$anonymous$$d of relying on bullet collisions. Will your player ever see the bullet? Just check the ray cast of the target sight to deter$$anonymous$$e what and where (barycentric) you hit, then put a small delay in and just have the bullet impact effects happen then.
Your answer
![](https://koobas.hobune.stream/wayback/20220613121515im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Character Respawn 1 Answer
FPS RIGIDBODY PROBLEM 1 Answer
FPS camera script - keeps reverting to 0,0,0 rotation 1 Answer
Question about FPS Player Script 1 Answer
FPS Tutorial problem 1 Answer