- Home /
Camera Shake on pressing Fire1 (used to fire bullets)..
hello everyone... this is my first post.. my question is that i have a camera shake script and i want it to shake the camera only when i press fire button...(in this case it is left mouse button)..
i am not able to get it right as it is shaking just in the beginning of the game..not when i press fire1.. please help..
here is my script...
var Cam: Transform; var Shake: float = 0; var ShakeAmount = 0.3; var BringDownTimer: float = 1;
function Update (){
if(Input.GetButtonDown("Fire1"))
if ( Shake < 0 ){
Shake = 0;
} if ( Shake > 0 ){
Cam.transform.localPosition = Random.insideUnitCircle ShakeAmount; Shake -= Time.deltaTime BringDownTimer;
} else{ Shake = 0;
}
}
It might be easier to quickly make an animation which shakes the camera for in this example a second then stops and just play the animation every time? :)