- Home /
FPS recoil, lerp fighting
I have recently encountered a seemingly simple problem which is giving me a hard time. I want a weapon to kick-back, but in a specific way. I want a camera to be rotated with lerp couple inches upwards, and when it gets there, another lerp should rotate camera back to its starting position. I know that it can be done like this
void Update () {
transform.localRotation = Quaternion.Lerp(transform.localRotation, new Quaternion(0,0,0,1), Time.deltaTime*5);
}
void KickBack(float power){
transform.localRotation = Quaternion.Lerp(transform.localRotation, new Quaternion(transform.localRotation.y - power, 0, 0, 1), Time.deltaTime * power);
}
but it's not very flexible way. I want to avoid "lerp fight", be able to set a maximum distance and make weapon to kick more to the right than to the left(for example). I tried to use coroutines but i probably can't use them properly anyways.
Thanks in advance :3
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to make a camera recoil system 0 Answers
pause for dastardly bannana 1 Answer
Weapon Switching 2 Answers
HDRP Camera weapon layer 1 Answer