function Start() {
player = GameObject.FindWithTag("Player").transform;
}
It is possible to initialize variables outside of a function, but usually only a good idea when using constant expressions (like 5, "chicken", 3.14, etc.).
Past that, is the script attached to anything in the scene? You can check to make sure a function is being called with a simple Debug.Log() call:
function Start() {
Debug.Log("Start is called");
//other code
}
You might also check to make sure that the player transform is, indeed, being found:
function Start() {
player = GameObject.FindWithTag("Player").transform;
if (player != null) {
Debug.Log("Found player");
} else {
Debug.Log("No player found");
}
}
So it turns out that because the levels are additively loaded, the find with tag function wasn’t working as the player hadn’t as yet been loaded into the scene. I put the findwithtag function inside onUpdate, and now it works. One small problem… all my code says is “rotate toward player”… my wolves have started flying. Now I’m really confused.