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.

I don’t know exactly how to use the raycast system. Here my moving script code. How to implement the raycasting system to this ? Sorry for noob question…

    void Update()
        if (Input.GetKey(KeyCode.RightArrow))
            rb.MovePosition(rb.position + transform.right * 50 * Time.deltaTime);


If the object is kinematic, it means that no physics’ method applies to the object: no gravity, no force, and no collision. Did you search what “isKinematic” boolean means?

If isKinematic is enabled, Forces, collisions, or joints will not affect
the rigidbody anymore.
Unity - Scripting API: Rigidbody.isKinematic

If you don’t really want it to be kinematic, just disable it.