- Home /
Problem with lerping Y axis
I'm trying to make a recoil script that quickly moves the Y axis of the main camera down a bit, then moves it back up. I've done this before with animations, but I don't want to use animations for this new script because they tend to be choppy and slow. Right now, this is what I have:
GameObject.FindWithTag("MainCamera").transform.position.y = Mathf.Lerp (GameObject.FindWithTag("MainCamera").transform.position.y, GameObject.FindWithTag("MainCamera").transform.position.y - recoilAmount, Time.deltaTime * 5);
I don't get any errors, but when I run the game, it doesn't do anything when I land. I know it's running the code, but nothing happens. Here's the full script in case you need it. The code above can be found towards the bottom of the script, right above the checkMaterial() function:
http://dl.dropbox.com/u/2318787/Footsteps.js
I would have just posted the code in here, but it wasn't pasting properly. The format kept getting messed up. It's a full 8 kilobytes, so it shouldn't be to much of a problem.
Thanks for any help.
PS: I don't know if I can use Vector3 rather than mathf. Vector3 seems a little unnecessary though, as I only want to lerp the Y axis. Not the X or Z.