I have this piece of script where i clamp my game object position. my object should stop at 3.7 but it goes till 5.7 then clamps to 3.7. any Help would be appreciated!! Thank You in advance.
If you set x = 3 on one line, and then a few lines later you set x = 7, then when you're done x has a value of 7. It only remember the most recent value. At the moment you say "x = 7" it forgets that x used to be 3. "Clamp" is just a fancy way of changing a variable's current value; it doesn't have any effect on what happens to that variable in the future. You could set the same variable to a billion on the very next line of code, and the fact that you clamped it a moment ago would become irrelevant.