Hello, I have a strange problem.
I have a Transform Array and when the object is hit.
Debug log say correctly:
Destroyed " ObjectName"
but the object is not destroyed.
My code:
void OnTriggerEnter(Collider coll)
{
coll.enabled = false; //Not Work!
GameObject.DestroyObject(coll) //Not Work!;
Destroy(coll); //NotWork
print("Destroyed " + coll.name);
for (int i = 0; i < targets.Length; i++)
{
if(coll.name == targets*.name)*
{
RemoveAt(ref targets, i);
}
}
}
public static void RemoveAt(ref T[] arr, int index)
{
for (int a = index; a < arr.Length - 1; a++)
{
arr[a] = arr[a + 1];
}
Array.Resize(ref arr, arr.Length - 1);
}
Editor Say:
> Destroyed RoseCut
> UnityEngine.MonoBehaviour:print(Object)
> SmoothFollow2:OnTriggerEnter(Collider)
> (at
> Assets/Scripts/SmoothFollow2.cs:101)