I want the player to trigger a script that checks for all instantiated prefabs, and destroys them when they’re too far away.
I’m successfully using an instantiate trigger script using C# but actually having the following issue:
In C# i have to specify the type of the object and cast to it in order to be able to manipulate the properties. This is particularly important if i instantiate a prefab object and want to edit it on the fly. The problem i am having is that the gameobjects and prefabs aren’t recognized as valid types, even though everything i read indicates they should be. The error happens at compile time, so i can’t even compile it. Normally in C# you would just add the correct namespace to reference an type, but in Unity3d i am not sure what i need to do and online searches haven’t helped. Error is here below.
error CS0246: The type or namespace name `GameObjectNameHere’ could not be found. Are you missing a using directive or an assembly reference?
For example, i can’t type public GameObjectName testName = (GameObjectName)Instantiate(parm1,parm2,parm3);
Thanks for any help!!