Hello, just wondering if some1 could help me im current developing a voxel based game and im in the middle of creating lanterns, an so what im trying to do is once i have placed my block im instantiating a Light and then renaming it such as Light#0, Light#1, Light#2 and so on and this brings me to my question im having trouble with after its been renamed so its no longer Light(Clone) once i destroy the block i want the light to be destroyed also some how but im not exactly sure how to go about Getting the exact Light as you can probably tell, i did try useing RayCasts but they just hit the block and not the light source… … :l - any help is greatly appreshiated & sorry if my code is a little all over the place im semi new to C#…
P.S: Dont think my code below is Functional it will most likely have errors i left it As is just so if anyone can help they have a better understanding of Exactly what my issues is and kinda what i want my outcome to be just incase i didnt explain it well enough.
using UnityEngine;
using System.Collections;
public class TorchID : MonoBehaviour {
private int i;
public Transform RedLight;
public void OnTorchPlace ()
{
Debug.Log ("Lantern has been Placed");
var t = GameObject.Find ("RedLight(Clone)");
t.name = "LightSource#" + i;
i++;
}
public void torchDestroyed()
{
Debug.Log ("Lantern has been Destroyed");
Destroy (GameObject.Find ( transform.LookAt(RedLight)));
}
}