void RayCast() { { int layerMask = 100; int x = Screen.width / 2; int y = Screen.height / 2; Camera Cam = CameraObject.GetComponent <Camera>(); Ray ray = Cam.ScreenPointToRay(new Vector3(x, y)); RaycastHit hit; if (Physics.Raycast(ray, out hit, layerMask)) { PickUp p = hit.collider.GetComponent <PickUp>(); if (p != null) { if (Input.GetMouseButtonDown(0)) { if (UseGun(FreezeChargeCost)) { p.FreezeObject(); //AudioPlayer.clip = TM_Effect; //print("Freeze Object"); //if (CurrentCharge < 20f) //{ //vignette.color.value = new Color(0, 217, 255, 5); //vignette.color.value = Color.black; // vignette.intensity.value = 0.268f; // vignette.color.Interp(Color.black, new Color(0, 217, 255, 5), 0.01f); // } } } else if (hit.distance < 8f && Input.GetMouseButtonDown(1)) { //if (UseGun(PickupChargeCost)) //{ print("Pickup Object"); p.PickupObject(); ArbiterHolder.Play("Fire"); //} } else if (Input.GetMouseButtonDown(2)) { //if (UseGun(PickupChargeCost)) //{ if (savedVelocity == new Vector3(0, 0, 0)) { savedVelocity = p.VelocityTake(); } else { p.VelocityApply(savedVelocity); savedVelocity = new Vector3(0, 0, 0); } //} } return; } else { print(hit.collider.tag); CubeSpawner CS = hit.collider.GetComponent <CubeSpawner>(); if (CS != null) { if (Input.GetMouseButtonDown(0)) { CS.RespawnCube(); } return; } SwitchToggle ST = hit.collider.GetComponent <SwitchToggle>(); if (ST != null) { // print("1"); if (Input.GetMouseButtonDown(1)) { //print("2"); UseGun(ST.Toggle()); } else { if (ST.resetable) { UseGun(ST.Reset()); } } return; } PowerSource PS = hit.collider.GetComponent <PowerSource>(); if (PS != null & Input.GetMouseButtonDown(1)) { // print("1"); if (Input.GetMouseButtonDown(1)) { //print("2"); if (PS.Use()) { CurrentCharge = MaxCharge; } } return; } } UseGun(0); AudioSource.PlayOneShot(Miss); } } }