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?
\$\begingroup\$
\$\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
Add a comment
|
1 Answer
\$\begingroup\$
\$\endgroup\$
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.