// Update is called once per frame
void Update () {
Vector3 fwd = transform.TransformDirection (Vector3.forward);
RaycastHit hit;
if (Input.GetButton ("Fire1") && mermi > 0 && shottime <= Time.time) {
Instantiate (muzzleFlash, muzzleSpawn.position, muzzleSpawn.rotation);
shottime = Time.time + firerate;
audio.PlayOneShot (AtesSes);
m4a1.animation.Play ("Gun01Shoot");
wepcam.animation.Play ("spreading");
mermi --;
if (Physics.Raycast (Kamera.position, fwd, out hit)) {
Debug.Log (hit.transform.gameObject.name);
if (hit.transform.gameObject.tag == "Dusman") {
Can can = hit.transform.gameObject.GetComponent<Can> ();
can.Healt -= 50;
}
}
{
if (decalHitWall && hit.transform.tag == "Level Parts")
Instantiate (decalHitWall, hit.point + (hit.normal * floatInFrontOfWall), Quaternion.LookRotation (hit.normal));
}
{
if (blood && hit.transform.tag == "Dusman")
Instantiate (blood, hit.point + (hit.normal * floatInFrontOfWall2), Quaternion.LookRotation (hit.normal));
}
}
if (reload == false && Input.GetKey(KeyCode.W) || reload == false && Input.GetKey(KeyCode.A) || reload == false && Input.GetKey(KeyCode.S) || reload == false && Input.GetKey(KeyCode.D))
{
Anitabanca.animation.CrossFade ("Gun01Walk");
}
if (reload == false && Input.GetKeyUp(KeyCode.W) || reload == false && Input.GetKeyUp(KeyCode.A) || reload == false && Input.GetKeyUp(KeyCode.S) || reload == false && Input.GetKeyUp(KeyCode.D))
{
Anitabanca.animation.CrossFade ("Gun01Idle");
}
if (mermi <= 0 && sayi > 0) {
if (Input.GetKeyDown (KeyCode.R)) {
reload = true;
audio.PlayOneShot (Reload);
m4a1.animation.CrossFade ("Gun01Reload");
StartCoroutine (Example ());
}
}
}
void OnGUI()
{
GUI.Box(new Rect(Screen.width-Screen.width*0.1f,Screen.height-Screen.height*0.1f, 50, 100), mermi + "/" + sarjor * sayi , customGuiStyle);
}
IEnumerator Example(){
yield return new WaitForSeconds(2);
if (mermi <= 0 && sayi > 0)
{
mermi += sarjor;
sayi--;
reload = false;
}
}
}
Please format your code. Edit your post, high light the code, click on the 101010 button and save it. Unformatted code will most likely result in no answers
– Landernbut i wanna fire in circle not only left or right
– lastquaker@lastquaker - you marked the answer as correct, and then I found the above comment in the Question queue. So I'm confused as to whether your issue is resolved or not. You are unlikely to get much additional help after you mark your questions as resolved.
– robertbu