- Home /
Ball goes through wall (2D)
The 2D Ball in my game is going through walls when I move it too fast. I have checked everything. All the walls have collider and it is not set to isTrigger. I'm pretty sure the code doesn't have to do with anything.
For more context, I created a walls and put a ball inside it. The script down below is for the walls and when I rotate the walls the ball inside is moving as well. That is exactly what I want but the only problem is the ball. It seems to force its way through.
public class RotateObject : MonoBehaviour { void Update() { Vector2 dir = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position; float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; Quaternion rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward); transform.rotation = rotation; } }
Your answer
![](https://koobas.hobune.stream/wayback/20220613044916im_/https://answers.unity.com/themes/thub/images/avi.jpg)