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 Graeme P · Mar 03, 2012 at 02:48 PM · vector3variablesnotupdating

Verctor3 isnt updating with variables

 var jumpPower = 8;
 var rotationSpeed = 100;
 var tuckSpeed     = 1;    
 var runSet        = 1;    
     
 private var speed : Vector3 = Vector3 (6, 0, 0) * runSet;    
 private var jump  : Vector3 = Vector3 (0, 1, 0) * jumpPower;

Hi Guys,

In need of some help, for some reason my vector3s here arent taking the update values of runSet and jumpPower.

Do you have any idea why this is please?

Thanks!

[Edit by Berenger : Code Formatting]

Comment
Add comment · Show 3
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 Graeme P · Mar 03, 2012 at 02:50 PM 0
Share

That is that they use the values listed here, but when the game is running and those values change, the vector3 continues to use the origenal value ins$$anonymous$$d of the new ones.

avatar image Owen-Reynolds · Mar 03, 2012 at 04:16 PM 0
Share

Do you mean that when you change jumpPower=5 to jumpPower=8 the Inspector still shows 5? That's a feature. Anything you can see in the Inspector is meant to override declare values.

avatar image Graeme P · Mar 03, 2012 at 05:20 PM 0
Share

No, I mean that when the game is running, the values for runSet and jumpPower change. But when they do the value of each in these Vector3 declarations stay as they were on load up, ins$$anonymous$$d of using the updated values like they should - Ive got my game working by moving "Vector3 (0, 1, 0) * jumpPower;" into my function update, but that is pretty messy.

I'm going to leave the question up in-case someone knows why it wasn't working in the first place thought, i cant see any reason for it to not have been working...

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Berenger · Mar 03, 2012 at 06:16 PM

speed and jump need to be recalculed in a function called every frame like Update. What you wrote, it's called only once.

Comment
Add comment · Show 2 · 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 Owen-Reynolds · Mar 03, 2012 at 08:26 PM 1
Share

Or if you only change runSet and jumpPower occasionally, you can also recalc speed and jump right then. But either way, assignments never "track" what they were based on an auto-update.

avatar image Graeme P · Mar 05, 2012 at 01:08 PM 0
Share

Thankyou for explaining that to me, I always assumed that if variables changed then the assignments would update too.

Thanks again for your help Berenger & Owen Reynolds!

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

6 People are following this question.

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

Related Questions

Script works with hard coded values but not variables 2 Answers

Get list of updating transforms 0 Answers

Updating variables from dictionary database in edit mode C# 0 Answers

How to make Vector3s communicate with Floats? 2 Answers

When does Unity calculate vectors' magnitudes? 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