public void FireKnife() { if (knifetimer < 2.5f) { var fire = 0; move.knifejump(); cam.transform.rotation *= Quaternion.Euler(.4f, 0, 0.0f); //Weaponry.GetComponent<weaponry>().KnifeStab(); //KnifeBody.GetComponent<Animator>().SetTrigger("stab"); //stores location of raycast hit RaycastHit hit; //makes raycast avoid game-layer with player and ui int layerMask = (1 << 8) | (1 << 9); layerMask = ~layerMask; //casts ray if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, KnifeWeaponRange, layerMask)) { //makes an impact particle effect HitBox target = hit.transform.GetComponent <HitBox>(); // this checks to see if object hit has a certain script if (target != null) { if (fire == 0) { KN.SetTrigger("GrabStab"); //target.HitByProjectile(KnifeDamage); GameObject blik = Instantiate(blood, hit.point, Quaternion.LookRotation(hit.normal)) as GameObject; blik.transform.SetParent(target.transform); target.KnifeHit(KnifeDamage); fire = 1; } } } else { KN.SetTrigger("stab"); } knifetimer = 2; } }