0
\$\begingroup\$

I was making a simple Pong game and it worked fine until I tried to increase the speed of the ball. With increased speed, the ball moves across the walls occasionally. I've set no rigidbody for the walls and dynamic rigidbodies for players and the ball. Surely, all of them have colliders. I check collision with OnTriggerEnter2D and all colliders are triggers. How can I solve this problem besides just hard coding collisions?

\$\endgroup\$
1
  • \$\begingroup\$ How do you move your ball at present? How are your walls set up? \$\endgroup\$
    – DMGregory
    Commented Apr 3, 2020 at 15:12

1 Answer 1

1
\$\begingroup\$

I found a solution! In order to get a proper collision detection you should use Kinematic body type in Rigidbody2D properties and move the ball with Rigidbody2D.MovePosition in FixedUpdate instead of transform.Translate in Update method.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .