Please Delete This Topic, I Figured It Out
First of all, attach AIFollow to an object in your scene. I’m assuming that you already did that, given that you’re getting errors. Next, create a sphere and name it “target”. Drag it from the scene to the variable “target” of the AIFollow script assigned to your object in your scene, not the prefab. unity won’t let you link things up like that in a prefab, you have to do it in the scene.
Do the same things with your main camera, except give it the “Clicker” script. Also, assign the “Seeker” script to whatever it is that you have AIFollow attacked to. You should now be good to go!
Just so you know, your error wasn’t specific to C#, it happens regardless of language. You can’t assign a variable on a prefab.
Thats not what I wanted… I’m using the instantiate function, and every time I try to instantiate it, the variable is unassigned… Thanks, though
As was mentioned above, this doesn’t sound like a language issue, but rather a problem with how you’re using the script.
insert a line of code that assigns the target on start
void Start ()
{
//some other stuff
target = GameObject.Find("target");
}
should work.
Where do I put it in?
The Start function has to go inside the class definition.
Sorry, but what/where is Class Definition?