- Home /
randomised camera "recoil"
I want my camera to shake when my Shoot animation plays , i have working script but the camera faces straight when it plays , so if i look up and shoot the camera quickly looks straight forward then goes back to its position , Im so confused , please help me ( Oh the camera shake for my script is an animation)
Well it is hard to help you if you don't post that specific part of the code, as I cannot see where you went in the mist with it.
As for now check whether you are rotating/moving it in Local space and not World space in your script (transform.localRotation/localPosition). local rotation will rotate based on the current rotation of the object, World will adjust it to the rotation based off the world. Also if you are using eulerAngles you will always face the same direction (wich is what you are getting), so I suspect you are using them. If so you need to step away from Euler because they are world based.
Im new to scripting and i have NO idea what you just said ... All i did was make a function called CamShake , And in that function i put animation.Play("camshake") , and it playsif my gun shoots .
Is it possible for you to post the script so we can help you improve/fix it?
See that is why it is smart to give a sample of your code, because I had no idea you where talking about an animation,i asumed you scripted the shaking. I see you edited your text now :).
But still without a script we can't be much of a help.
do you want the whole script or a sample? ill give you a sample
GameObject.Find("ump").animation.Play("ShootU$$anonymous$$P");
CamShake ();
function CamShake () {
GameObject.Find("$$anonymous$$ainCamera").animation.CrossFade("CameraShake");
}
thats it , i'm pretty useless at transform.rotation or whatever it is , i have no idea how that works
Answer by AlucardJay · Oct 14, 2013 at 09:23 AM
You have probably animated the camera, so it is using world-space positions/rotations when you play the animation. Make the camera a child of an empty gameObject, then make the animation again, just animate the child camera object. Now wherever the empty gameObject containing the camera is placed, when you play the animation it should work in local-space positions/rotations (relative to the empty).
Your answer
![](https://koobas.hobune.stream/wayback/20220613115802im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Make a camera collision 1 Answer
How to make camera position relative to a specific target. 1 Answer
Switch to a random camera 1 Answer
Spawning prefab on x axis inside the camera 2 Answers
Random camera orientation 1 Answer