- Home /
Mathf.SmoothDamp and vSync
Hello, I noticed that if you use SmoothDamp with vSync on (~60FPS) everything works fine, but if you turn off vSync (~2000FPS) the SmoothDamp function seems to work slower, basically with vSync on it takes me just 1 second to crouch, with vSync off it takes me about 3-4 seconds to crouch. I've tried to put the code inside FixedUpdate but it becomes jitter. Here's the code:
float crouchVelocity = 0;
controller.height = Mathf.SmoothDamp(controller.height, 1.25f, ref crouchVelocity, 0.035f);
Any suggestions?
Answer by Tryz · May 02, 2014 at 06:07 PM
I found the same thing. I was able to fix this by making the last argument (smoothTime) relative to the frame rate.
If at 60 FPS (0.016 ms per frame), you want a smoothTime of 0.035... that's 0.016 x 2.
So, I did this...
controller.height = Mathf.SmoothDamp(controller.height, 1.25f, ref crouchVelocity, Time.deltaTime * 2f);
Your answer
Follow this Question
Related Questions
Changing Targets - Smooth Damping X and Z on SmoothFollowCamera 0 Answers
why target switching of smooth camera not very smooth ? 0 Answers
Does SmoothDamp reach target? 2 Answers
Second Camera Tearing on Android 1 Answer
WaitForTargetFps using high cpu 0 Answers