Just want it so that when the ray cast hits the cube (with a red material) it turns to blue. I am successfully using the ray cast, but getting no result with change colour.
//Raycast against tiles
var fwd = transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
if(Physics.Raycast(transform.position, fwd, hit, 10))
{
Debug.Log("Hit");
if(hit.trigger.gameObject.name == "Red")
{
print ("Hit Red Box");
renderer.material.color = Color.blue; //Obviously didn't work
}
}
Debug.DrawRay(transform.position, fwd * 10, Color.green);
}
Thanks, guys.