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 DricoJD · Nov 01, 2013 at 05:31 PM · variableshierarchystrings

script ignoring variables when assigning them in the hierarchy

Problem

So today I was working on an age system, to improve my knowledge of JavaScript, all was going well till I wanted to have an output of age... It works okay, no bugs or anything like that; the only problem is, the variables I input from the hierarchy does not change the personsAge final output, like the sums are done perfectly - if I change the sum inside the script it comes out the way it should, but if I want to change the the variable dateYear it does not update the sum inside of the script, so it comes up with the answer that I clarified in the script before (default int number). However it does change the actual year that shows on the input so I know that the dateYear variable is working, just the personsAge variable has something wrong I believe that is stopping any input from the hierarchy.

Code:

Here is my script:

 //DateOfBirth
 
 var dateMonth : int = 12;
 var dateYear : int = 1996;
 var dateDay : int = 31;
 var currentYear : int = 2013;
 var personsAge : int = (currentYear) - (dateYear);
 
 //Name
 
 var forename : String = "John";
 var surename : String = "Doe";
 
 //Define Name and Birth Date and age.
 function Start()
 {
 
 print ("Name: "+ forename +" "+ surename +" BirthDate: " + dateDay +"/"+ dateMonth +"/"+ dateYear +" Age: "+ personsAge); 
 }

Additional Info

If the hierarchy settings were the same as the code settings I would have a perfect output, however the variable personsAge seems to dislike the hierarchy.

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

0 Replies

· Add your reply
  • Sort: 

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

15 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

Related Questions

Using string to refer to variable 2 Answers

Accesing variable from another class for instantiated gameobjects 0 Answers

check if my variable is in the same position as the array 2 Answers

Is there a way to extend the amount of values for inspector? 0 Answers

Alter variables in other Game Objects 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