- Home /
How to have a object change another object's variables?
Hello, I'd like to be able to have my objects interact with other object's variable for collisions and such. In this case, I have a slime mob that will target food, and then move towards the food to eat it. Slimes keep all going after one piece of food, so I thought that I would have a reserved boolean so that they will each have their own targeted food, but I can't seem to figure out how to have the slime change the reserved variable to true in the food's foodscript.
Answer by Cycy · Oct 19, 2017 at 07:31 AM
Hello, i don't know if i well understand your pb : you want your slime to access and modify a foodscript's variable ?
If so :
aFoodGameObject.GetComponent<foodscript>().reservedBoolean = true; //or false
NB 1 : the reservedBoolean have to be public. If you dont want it to be public, create a get/set access or a public void to modify it.