- Home /
farming game with replanting problem
so i'm making a farming game where you grow colorful squares, and i'm having a little problem. you can click on a plot of land, and when you do that, a square grows, such as this
once you click to collect them, though, you can't replant them. i know why this is, for the plots of land have a variable that tells them if something is being grown on them or not, and that's not being reset.
the only problem with doing this is that i can't figure out how to set the variable to false! i assume that it has to go here -
i figure that i need some sort of way to identify which plot is being farmed, but that's something i don't know how to go about either, i'm very new to this. if anyone can help, that would be great!
EDIT: this is my full code for both scripts-
this should probably explain it a little better...
EDIT: i ended up making prefabs for all the plots and the plants, to try something out. i feel like that'll make things easier.
Answer by Jamora · Jul 10, 2013 at 09:50 PM
Because you seem extremely new to programming, this resource will most likely help you:
http://www.unityscript.com/lessons1/basics.php
To set a boolean false, you need booleanVariable = false;
To determine if anything is grown on a cube, have a script on it that keeps track what is grown on it.
i don't need to know how to set booleans, since i've been program$$anonymous$$g in game maker for about 3 years. i need an idea of how to create that script you're talking about, i literally have no idea how to go about this.
Answer by drew_massey · Jul 11, 2013 at 03:56 AM
You might want to post a little more of your code (probably entire script) so that we can get a full understanding of what you are trying to do... What I would suggest however, is that instead of Destroy(gameObject); (which is destroying the cube altogether), try setting the cube to inactive...
gameObject.SetActive(false);
This method will actually be a lot less CPU intensive as well (you aren't creating new instances of the object and destroying them.
Hope this helps!
-Drew
good idea about the setactive function! i'll post my full code in the main question now, so it's easier to view.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
if several variables is true then do function 2 Answers
Unity says there is no such thing as a boolean. 1 Answer
Use one variable to reference another variable 1 Answer
Referencing booleans from settings 1 Answer