strange behaviour of the collider

Hello Unityrs, I have my model from on OBJ file. I attach it a MeshCollider and in my script I set

obj.GetComponent().convex = true;

I run the script and I can see in the inspector that convex is enabled. Now, my OBJ also have a rigid body with ‘useGravity’ = false.
In the inspector I enable the ‘useGravity’ and the object doesn’t interact with anything in the scene (Just a cube and a big plane).
BUT if in the inspector I disable and enable again the ‘convex’ and I enable ‘useGravity’ everything is ok… WHY??? :frowning:

This is my code:

obj.AddComponent(typeof(MeshFilter));
obj.AddComponent(typeof(MeshRenderer));
obj.AddComponent(typeof(MeshCollider));
obj.AddComponent(typeof(Rigidbody));

obj.GetComponent().useGravity = false;
obj.GetComponent().isKinematic = false;
obj.GetComponent().convex = true;

I’m not really sure what you are attempting here. If you are adding a mesh filter and renderer to an empty GameObject then you need to set the mesh explicitly for the mesh filter and also for the collider. If there is already a visible mesh attached to the object then you don’t need to add the various components, you can just use MonoBehaviour properties or GetComponent to access them.