Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by brwiz · Jul 10, 2013 at 09:36 PM · bugvariablebooleanreference

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

alt text

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 -

alt text

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-

alt text

alt text

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image brwiz · Jul 11, 2013 at 03:22 AM 0
Share

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.

avatar image
0

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image brwiz · Jul 11, 2013 at 04:23 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges