Ok so based on the comment i made earlier here is how i would add offset to the camera. The code is just of the top of my head so it might need a bit of fine tuning:
//Inside the mouse tracking class
Vector2 offset = new Vector2();
float startTime = -1f.
//the code that controls the initial recoil
private void Hit()
transform.rotation = Quaternion.Euler(transform.rotation.x - 10, transform.rotation.y, transform.rotation.z);
offset.x = 10f;
startTime = Time.time;
length = Vector2.Distance(new Vector2, offset);
//replace the part were you get the mouse position with this method
if (startTime != -1f)
Vector2 mouse = Input.mouse.position,
adjustedMouse = mouse + offset;
//change the 10 to speedup/slow down the transition back to normal
float dist = (Time.time - startTime) * 10f,
fracJourney = dist / length;
if (dist >= 1f)
startTime = -1f;
offset.x = 0f;
return Vector2.Lerp(adjustedMouse, mouse, dist);
When you want to trigger the recoil call "Hit" which will setup all the variables for the Lerp. Then instead of checking the input class for the position of the mouse on screen, call the "Recoil" method which should pull the mouse up and then slowly lower it to the actual position of the gun.
You can read up on what I did here but for the sake of completeness:
Linearly interpolates between two vectors.
Interpolates between the vectors a and b by the interpolant t. The
parameter t is clamped to the range [0, 1]. This is most commonly used
to find a point some fraction of the way along a line between two
endpoints (e.g. to move an object gradually between those points).
I hope this works for you :)