Stop raycasting for close distance

Hello everyone, I have my raycast shooting code but I want it not to raycast to the collisions which is too close to player. I want it because I’m using Camera.main.ScreenPointToRay so it sometimes collides with itself, let me explain with some pics :

alt text

I mean when I look down it collides with itself and particles are being seen very ridiculusly, so is there anything I can do for not to Raycast too close ?

Here is my code :

    function Start(){
    hitParticles = gun.GetComponentInChildren(ParticleEmitter);
    if (hitParticles)

function Update(){
    var hit : RaycastHit;
    var ray = Camera.main.ScreenPointToRay (Vector3(Screen.width/2,Screen.height/2));
    if(Input.GetMouseButton(0)&& Time.time > nextFire){
    nextFire = Time.time + fireRate;
    if (Physics.Raycast(ray,hit,100)){
        Debug.DrawLine( transform.position, hit.point,;
                if (hitParticles) {
    			hitParticles.transform.position = hit.point;
    			hitParticles.transform.rotation = Quaternion.LookRotation(hit.normal);


You can just check the distance property of the RaycastHit and not do anything if it’s too short.