When I instantiate a bullet hole on a cube it starts flickering and this is something that I find unpleasant for my game, but when I instantiate a bullet hole on a rounded surface, like a capsule, it doesn’t flicker. So how do I fix this? Here’s what I mean: http://videobam.com/LcUNs
Here’s my script:
var Barrel : RaycastHit;
var Cam : Camera;
var BulletHole : GameObject
function Update () {
hitRotation = Quaternion.LookRotation(Barrel.normal, transform.up);
}
function Shoot () {
if(Physics.Raycast(transform.position, Cam.transform.forward, Barrel, 60)){
yield WaitForSeconds(0.1);
var newBulletHole = Instantiate(BulletHole, Barrel.point, hitRotation);
newBulletHole.transform.up = Barrel.normal;
CurrentAmmo -= 1;
print("The ammo of the MTAR is " + CurrentAmmo);
newBulletHole.transform.parent = Barrel.transform;
if(Barrel.transform.tag == "Player"){
Barrel.rigidbody.AddForce(Cam.transform.forward * BulletImpactForce);
}
if(Barrel.transform.tag == "Detail"){
Barrel.rigidbody.AddForce(Cam.transform.forward * BulletImpactForce);
}
}
}