How to load material onto sphere?

I have a cylinder, which when collides with a sphere, it creates another sphere in the scene through javascript.

I can add rigidbody component, but don’t know how to change the material of the sphere that is generated…

function OnCollisionEnter (col : Collision)
{	
	var hoverForce = 150;
    if(col.gameObject.name == "Sphere")
    {	
       	if (col.rigidbody) {
			col.rigidbody.AddForce(Vector3.up * hoverForce, ForceMode.Acceleration);
		}
		var sphereB : GameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
		sphereB.AddComponent(Rigidbody);
		sphereB.transform.position = Vector3(0, 5, 0);
		//GetComponent<Renderer>().material = ball_texture;
    }
    
}

Renderer.material seems to be depreciated, so how would I change it?

Thanks

sphereB.GetComponent(Renderer).material

transform is the only shortcut left, all other components you need to get with GetComponent.

Hint: create a prefab with Rigidbody and the right material and spawn that instead.