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