MC_HALO
1
Hello guys i was wondering can someone help me. How can i make a simple camera shake script so when the player presses the F key the camera shakes 
thank you in advance 
Stardog
3
Or you can use iTween's ShakePosition.
http://itween.pixelplacement.com/documentation.php
if (Input.GetKeyDown(KeyCode.F)){
iTween.ShakePosition(gameObject, Vector3(1,0,0), 1)
}
gameObject being the object the script is attached to.
ShakePosition(GameObject target, Vector3 amount, float time)
system
2
Ok, I might as well share. I made this awesome script that makes the camera shake, here it is:
static var shakeInt = 50.0;
var decrease = 5.0;
var magnitude = 5.0;
function Update () {
if (shakeInt < 0){
shakeInt = 0;
}
if (shakeInt != 0){
shakeInt -= 1*decrease*shakeInt*Time.deltaTime;
}
var cam = camera.main.transform;
if (shakeInt > 0){
cam.rotation.x += Random.Range(-magnitude*shakeInt, magnitude*shakeInt);
cam.rotation.y += Random.Range(-magnitude*shakeInt, magnitude*shakeInt);
cam.rotation.z += Random.Range(-magnitude*shakeInt, magnitude*shakeInt);
}
}
So, that’s the main script. In your project folder, name it “Shake”. Decrease is how fast it stops shaking, magnitude is, well, self-explanitory
I recommend setting magnitude really low. Also, this deals with camera shake only. You will need to attach a smooth look at script to your camera as well. So, how to access the shake itself? being a static variable, you can access it through other scripts like this (example):
if (Input.GetKeyDown("f")){
Shake.shakeInt = 20.0;
}
Hope this helped you!