Last active
December 19, 2015 13:38
-
-
Save nklsrh/5962983 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in case the Lerp function produces a value above max paddle speed, we clamp it | |
if (Math.abs(paddle2DirY) <= paddleSpeed) | |
{ | |
paddle2.position.y += paddle2DirY; | |
} | |
// if the lerp value is too high, we have to limit speed to paddleSpeed | |
else | |
{ | |
// if paddle is lerping in +ve direction | |
if (paddle2DirY > paddleSpeed) | |
{ | |
paddle2.position.y += paddleSpeed; | |
} | |
// if paddle is lerping in -ve direction | |
else if (paddle2DirY < -paddleSpeed) | |
{ | |
paddle2.position.y -= paddleSpeed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment