Here is the code folks:
using UnityEngine;
using System.Collections;
public class LeBrick : MonoBehaviour {
GameObject[] objMatToCompTo;
// Use this for initialization
void Start () {
objMatToCompTo = Resources.LoadAll("(1)BlockPreFab") as GameObject[];
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.name == "Ball")
{
Debug.Log("hit");
switch(gameObject.renderer.material.name)
{
case "1":
Debug.Log("destroyed?");
Destroy(gameObject);
break;
case "2":
gameObject.renderer.material = objMatToCompTo[0].renderer.material;
break;
case "3":
gameObject.renderer.material = objMatToCompTo[1].renderer.material;
break;
default:
break;
}
}
}
}
hit! prints, destroyed doesnt…
I worked this a few hours, and still can’t find the problem…
appreciate any help! =]