- Home /
Bringing one value closer to another
I am having some issues with comparing and changing some values within my code, I want to test if one value is above another and then change to get closer to the other value. Although what i have works to an extent there are a couple of problems with it. The key problem is that once it reaches almost the same value it will 'flicker' between them never actually reaching the right value as it overshoots it with each change. The second slightly smaller problem is this feels like a fairly 'bulky' way of doing it, is there a function available that will simply bring one value closer to the other?
Ok so no matter what i do this is refusing to display my code properly and removes chunks of it, I apologise for clearly being inept at this. Here is a link to the pastebin of my script: http://pastebin.com/TMGRmbTA
Answer by PAEvenson · Feb 07, 2013 at 05:09 PM
You can trying lerping. http://docs.unity3d.com/Documentation/ScriptReference/Mathf.Lerp.html