Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

NullReferenceException. No idea why it does that. Help.

$
0
0
So, ive been trying to fix this like 3 hours straight, and nothing works.. Here is the save script : public void Save() { Objects = 0; objects = GameObject.FindGameObjectsWithTag("WeedPlant"); if (objects != null) { for (int i = 0; i < objects.Length; i++) { xPos[Objects] = objects[i].gameObject.transform.position.x; yPos[Objects] = objects[i].gameObject.transform.position.y; zPos[Objects] = objects[i].gameObject.transform.position.z; fert[Objects] = objects[i].GetComponent().Fert;//Error IsGrown[Objects] = objects[i].GetComponent().isGrown; //Error Grams[Objects] = objects[i].GetComponent().WeedQuant; //Error procces[Objects] = objects[i].GetComponent().pro; //Error water[Objects] = objects[i]GetComponent().Water; //Error plantType[Objects] = objects[i].GetComponent().PlantType; //Error Debug.Log("Plants saved : " + Objects); Objects++; } } } Here is the growing script : public class Growing : MonoBehaviour { [SerializeField] public Text weedText; public bool IsGrowing = true; public bool isGrown; private float x; private float y; private float z; private float height; private float height2; public int Water; public int WeedQuant; public int pro; public int PlantType; public bool Boosted; And in game i have plants with tags "WeedPlant" and Growing script attached to them, but it still says : NullReferenceException: Object reference not set to an instance of an object PlantWeed.Save () (at Assets/PlantWeed.cs:92)

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>