I’ve had this little idea for an FPS game and following the success with the few people that played the last game I finished I decided to go into it with a light heart.
However, I’ve come up against a couple of problems with it; my Vector3.Lerps do not seem to work as intended. I know it is something I’ve done and it’s almost certainly blindingly obvious to anyone else but I can’t see what’s wrong and so some help would be very much appreciated.
Relevant Code:
public Vector3 editingPosition;
public Vector3 originalPosition;
public Vector3 editingRotation;
public float editingFOV = 30.0f;
public float editingFOVAll = 45.0f;
public float defaultFOV = 60.0f;
public float timeToTake = 0.3f;
if(!isEditing){
transform.localPosition = Vector3.Lerp(originalPosition, editingPosition, 1f * Time.deltaTime * (timeToTake * 10));
transform.localRotation = Quaternion.Slerp(Quaternion.Euler (0,5.8f,0), Quaternion.Euler(editingRotation), 1f * Time.deltaTime * (timeToTake*10));
Camera.main.fieldOfView = Mathf.Lerp (Camera.main.fieldOfView, defaultFOV, 1f * Time.deltaTime * (timeToTake * 10));
weaponCamera.fieldOfView = Mathf.Lerp (weaponCamera.fieldOfView, defaultFOV, 1f * Time.deltaTime * (timeToTake * 10));
}
else{
transform.localPosition = Vector3.Lerp(editingPosition, originalPosition, 1f * Time.deltaTime * (timeToTake * 10));
transform.localRotation = Quaternion.Slerp(Quaternion.Euler(editingRotation), Quaternion.Euler (0,5.8f,0), 1f * Time.deltaTime * (timeToTake*10));
Camera.main.fieldOfView = Mathf.Lerp (Camera.main.fieldOfView, editingFOVAll, 1f * Time.deltaTime * (timeToTake * 10));
weaponCamera.fieldOfView = Mathf.Lerp (weaponCamera.fieldOfView, editingFOV, 1f * Time.deltaTime * (timeToTake * 10));
}
The problems I’m having is that the Vector3.Lerp isn’t moving the model at all (All the values are set in the editor to the correct places) and, though I took this from my other script where the Vector3.Lerp worked, however, it does not linearly interpolate but rather jump to the second location.
N.B. The Quaternion.Slerp and the Mathf.Lerp work as intended.
Any help to point out my errors would be very much appreciated.
Thanks.