I have an object using Mathf.Lerp and an offset variable for the y position like you see in the headbobber script.
My code is basically this:
if(bool == true){
offset = Mathf.Lerp(offset, desiredValue, speed * Time.deltaTime);
if(offset == desiredValue){
print ("Yeah");
bool = false;
}
}
This works, but my offset variable never actually reaches the desired value no matter the speed. This is really vital for a scripted animation I use for changing equipped items. Is there a way to ensure it reaches that value? No matter what I said the checked value it never prints, my gameobject needs to always end up in the same rest position.