0
\$\begingroup\$

I was making a simple pong game and it worked fine until I tried to increase speed of the ball. With increased speed ball moves across the walls occasionally. I've set no rigidbody for 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\$
  • \$\begingroup\$ How do you move your ball at present? How are your walls set up? \$\endgroup\$ – DMGregory Apr 3 at 15:12
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.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.