// Update is called once per frame void Update() { //aiming aimPos = aimCamera.ScreenToWorldPoint(Input.mousePosition); direction = aimPos - transform.position; direction.z = 0; Vector3 normal = new Vector3(-direction.y, direction.x, 0); aimPivot.rotation = Quaternion.LookRotation(direction, normal); //nice camera movement Vector3 offset = (aimPos - transform.position); offset = Vector3.ClampMagnitude(offset, viewMaxDistanceOffset); Vector3 cameraPos = offset * viewInterpolation + transform.position; cameraPos.z = viewCamera.transform.position.z; Vector3 localCameraPos = transform.worldToLocalMatrix * offset; localCameraPos.z = viewCamera.transform.localPosition.z; Vector3 interPolatedPosition = Vector3.SmoothDamp(viewCamera.transform.localPosition, localCameraPos, ref interpolationVelocity, interpolationTime); viewCamera.transform.localPosition = interPolatedPosition; //shooting if (Input.GetButtonDown("Fire1")) { laserManager.AddBeam(spawnPoint.position, spawnPoint.forward, this); shootSound.Play(); } }