Player goes through object even in FixedUpdate funcion

Hi, I implemented this code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour
{

    Rigidbody rb;
    public float speed;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        speed = 600;
    }

    void FixedUpdate()
    {
        Vector3 acc = Input.acceleration;
        
        transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z);
        rb.velocity = new Vector3(acc.x * 1000, -acc.y * 1500, speed);



        


    }
}

The problem is one, if I apply it to a sphere with rb and sphere collider, when I move with the accelerometer input, the collisions detection is working fine, if I crash against a surface going left/right/up/down, I can’t go trough that surface. If I inport other prefabs from blender or unity asset and apply the same script, with rb and mesh colliders(or I even tried with sphere collider), the object goes trough the same surface. Can someone explain me why? Thanks

If you have a Rigidbody on a GameObject, don’t directly set the transform.position.

Directly setting transform.position acts like a “teleport” and bypasses the physics system.

Instead use rb.MovePosition( newPosition) and then the physics system will be involved and have a chance to collide, trigger, etc.

NOTE: you can still move fast and far enough in a given frame to go through small objects. See different collision detection modes available to the Rigidbody.

Also, keep in mind the faster you move and the harder you spin, the more likely you are to get really weird things happening in physics. Discrete digitally simulated physics do best in a narrow range of perhaps \three or four orders of magnitude. Go above that and you will have problems and instabilities.