isKinematic object doesnt collide with wall

Hey i need help for my little game project.

I have a ball (has a collider and kinematic rigidbody) and i m moving that with “rb.MovePosition” method. But that can pass through walls. I dont want it. Walls are simple cubes and my ball should stop when collide a wall. Can you pls help me ?

@sefayilmaz A raycast:

Vector3 lastPos;

public void Start() {
lastPos = transform.position;

public void FixedUpdate()
lastPos = transform.position;

RaycastHit[] hits = Physics.RaycastAll(new Ray(lastPos, (transform.position - lastPos).normalized), (transform.position - lastPos).magnitude);

//Do something with it using hit
transform.position = hit[1].point;

If a collision dosnt occur in a visible frame, it didnt happen, so the raycast goes between where you were and where you are, and if there is a collision, then it teleports the object to the collision point, although I would recommend adding a offset based on half your size.