I’m taking a short break from my usual game work and building something relatively small and simple: Pong. I know these types of questions have been asked a hundred times before, but I can’t find a relevant answer with Google or the Answers search. At the moment, the game all but works. The ball and paddles move, I’ve got scoring/etc, and everything should be good. However, the ball has a nasty tendency to get “stuck” in a single motion, between walls. I would prefer for it to bounce off in another direction on a wall impact:
void FixedUpdate () {
if (ballMoving)
{
Vector3 currentVelocity = rigidbody.velocity;
Vector3 tVelocity = currentVelocity.normalized * constantSpeed;
resultVelocity = Vector3.Lerp(currentVelocity, tVelocity, Time.deltaTime * sFactor);
rigidbody.velocity = resultVelocity;
}
}