I’ve been reading though the forums, and haven’t found anything that points to my particular issue… this is seriously killing me. I get this message in the console:
“MissingReferenceException: The variable strafeleft of ‘Asteroidlvl10’ doesn’t exist anymore.
You probably need to reassign the strafeleft variable of the ‘Asteroidlvl10’ script in the inspector.
UnityEngine.Transform.get_localPosition ()
Asteroidlvl10.Update () (at Assets/Scripts/Asteroidlvl10.js:98)”
here is the snippet of code that it points too:
if(Input.GetButton("a"))
{
mark = 0;
speed = (movespeed/100) * distance;
movedirection = strafeleft.localPosition * distance;
movedirection.y = -12;
movedirection.x = movedirection.x * 10;
movedirection.z = movedirection.z * 10;
transform.position = Vector3.MoveTowards(transform.position, movedirection, speed*Time.deltaTime);
timerdrift = speed;
speed1 = speed;
}
I have created an asteroid prefab, and added a strafeleft empty gameobject to my ship. this is also a prefab. when the game starts asteroids are instantiated infront of the ship off screen. They fly past the screen based on the speed dictated in another line of script. The problem is that when the a key is depressed instead of the asteroid moving towards the strafeleft position it complains that the refernce doesn’t exist. in the instantiated clones of the asteroid prefab the gameobject strafeleft is missing. I assure you that the reference was made between the two prefabs and the prefabs are still intact in the project window. for the life of me I can’t figure out why the asteroid prefab drops strafeleft, but doesn’t drop any of the other references including ship which is a gameobject reference for the parent of strafeleft.
I hope that makes sense, but I really need help with this one. I’ve been messing with it for a couple of days and can’t figure it out.