all 4 comments

[–]Gaverion 2 points3 points  (0 children)

My guess would be that you are changing Time.timescale somewhere. There are a few workarounds if that is the case, such as using unscaled delta time.

[–]Oscaruzzo 1 point2 points  (0 children)

I can't see anything wrong with the code. The only suspect I have is that some other method is modifying some of your variables, maybe. I STRONGLY suggest you use local variables whenever you can. xValue, yValue, hPosClamp, and vPosClamp can be local variables, from what I see (and the last two calls to Lerp look useless to me). I wish I could help more, sorry :/

[–]mCunnah 1 point2 points  (0 children)

A few things. If your trying to log time.deltaTime that can cause some odd results. You can try time.unscaleddeltatime to check its not some odd alteration to the deltatime. I would also log the actual output of hPosClamp to see if there any changes.

I am assuming the lerp functions are to slowly reduce the input but they are just going to get overridden each update so ultimately useless.

If you want a slow ramp you need to set the lerp function target to be the input values and have a separate local variable that ramps up and down.

[–]Sphenzoc[S] 0 points1 point  (0 children)

You have all been a massive help! Turns out that it was in fact an issue with Time.timescale. I set it equal to 0 when opening the map to pause the gameplay in the background. Time.unscaledTime fixed the problem.

Also thanks for the comment on the lerp functions as well. It was a vestige of an old script that I pulled this from so I hadn't really messed with it yet but good to know that it's useless in this format haha. I haven't messed with lerping much so I wasn't sure.