How to stop textures flickering

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:

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);


Make the bullet hole prefabs SLIGHTLY in front of the cube. The reason it is flickering is because it is actually half in and half out of the cube, and it does not flicker on a curved surface because if you think about it, the surface curves away from the prefab so it is not actually inside the sphere. Move it slightly in front of the cube, like 0.001 would be enough.

you can override your position just by writing this line to stop flicking
Barrel.point = new Vector3 (Barrel.point.x - 0.001f,Barrel.point.y - 0.001f,Barrel.point.z - 0.001f);