How do I Stop Pong Ball Gravitating Towards Paddle?

Hello. I’m creating a Pong game in Unity to practice my skills as a beginner game dev, and have run into an issue where the ball gravitates toward a single paddle, and once it bounces off said paddle, it will simply gravitate back to that paddle.

Here is an example to demonstrate what I mean:

How can I fix this so that it doesn’t gravitate towards any paddle at all?

Logic bug:

you never change the speed parameter to the move the ball to the other side. Consider multiplying the speed’s X by -1 when the ball hits the platform

PS: please use code snippets next time instead of sharing a screen shot

You can remove the FixedUpdate. The ball doesn’t need a force constantly being added to it.

Add an OnCollisionEnter event to the bats so that when the ball collides with the bat it can be given a push with AddForce()

using UnityEngine;

public class PushIt : MonoBehaviour
{
    public Vector3 pushForce;


    void OnCollisionEnter(Collision collision)
    {
        collision.gameObject.GetComponent<Rigidbody>().AddForce(pushForce);
    }
}

Oh and you’ll need the walls to also push the ball when it hits them!. :slight_smile:

Thank you, this solved the problem. :slight_smile:

Thanks for your answer!

P.S. sorry, I will use code snippets next time

I actually like the effect! :slight_smile: Too bad it’s undesirable :slight_smile: