Hello. I am new at c# and unity. The problem that im facing is ;
I created such a script to destroy prefab instances(they are moving towards an axis and when they arrive a Z value I aim to destroy them.)(the value will be taken from a gameobject(children))
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Destroyer : MonoBehaviour
{
public Transform destroyPosition;
void Update ()
{
if(transform.position.z < destroyPosition.position.z)
{
Destroy(gameObject);
}
}
}
and attached this to a gameobject prefab.!
When I try to attach destroypoint to the destroyer script destroy position, it doesnt be attached into the prefab. But when i pull the prefab into the screen, on the instance I can attach the destroy position…
Where is the problem? Why cant i put the destroy position object into the destroy position in the prefab? Where do i do the mistake? Thanks for your explanation