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 Eeppi · Mar 05, 2013 at 01:45 PM · itweenbug-perhaps

iTween value doesnt change

 var dis:float;
 function Update () {
 iTween.MoveUpdate(gameObject,{"x":transform.position.x - dis}); 
 }

I'm setting float "dis" from another script. At the begginning it's 6, but when I change it on runtime to 4 or something, iTween doesnt move object, it still uses value 6. I can see that value is changing on editor, but iTween still doesnt use the new value.

Is this somekind iTween bug? How I can fix this?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Catlard · Mar 05, 2013 at 02:43 PM

Why are you using MoveUpdate instead of MoveTo? Why are you using MoveUpdate without specifying an update function for the call to refer to?

Using the iTween.Hash function is good. Check that out.

Possible reason this is happening -- is it possible you are adjusting a public variable in the script, and not in the inspector? Make sure that the variable "dis" is private, and then try changing it again.

Let me know how it goes?

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 Eeppi · Mar 06, 2013 at 02:25 PM 0
Share

I'm using $$anonymous$$oveUpdate since $$anonymous$$oveTo is too laggy for my usage since i'm changing positions in realtime (Example on my first post is just example, it's not from my actual code). I dont understand what you mean with "Why are you using $$anonymous$$oveUpdate without specifying an update function for the call to refer to?", iTween documentation doesnt speak anything about specifying update functions.

I cant really change variable in inspector since variable value is defined on another script, for the same reason I cant put it private, cos other scripts cant find it then.

avatar image Catlard · Mar 06, 2013 at 11:27 PM 0
Share

FIRST: Often, to keep variables "safe", I'll make them private, so they can't be seen/changed in the inspector. Then I create a "get" or "set" function -- something that just returns the value of the variable. They have this in c#, but you can make your own in Javascript. It makes things simpler in the long run. Often, the key to fixing bugs like this is to simplify your code by using tools like this. This thread will help you figure them out. :

http://forum.unity3d.com/threads/99568-UnityScript-Getter-Setter-Are-they-supposed-to-work

SECOND: It's true, the itween documentation doesn't really describe update functions very well. But here's an example of how my itween "update" functions work, in c#. ValueTo works the same way $$anonymous$$oveUpdate does. I'm sure you can see how it would work in java/unityscript. First, you have the itween call, which occurs somewhere in code.

     iTween.ValueTo( _pageToScroll, iTween.Hash("from", _movementDir, "to", Vector3.zero, "islocal", true, "onupdatetarget", gameObject, "onupdate", "UpdateThrow", "time", Annotation$$anonymous$$itchen.instance._timeToStopDriftingAfterThrow , "easetype", Annotation$$anonymous$$itchen.instance._stoppingEaseTypeAfterThrowing, "oncompletetarget", gameObject, "oncomplete", "StopDrifting" ));

In that code, there's a reference to an "onupdate" function called "UpdateThrow". That function looks like this:

 public void UpdateThrow( Vector3 newValue )
     { }

The "newValue" accepted by the function "UpdateThrow" is the updated value. Just make sure that you also specify the "onupdatetarget" in the itween call. Otherwise it won't work.

Does that help?

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

11 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

Related Questions

iTween MoveTo: Object doesn't quite reach the target position 0 Answers

Rotation 90.0001 and 1.001719 bugs! 1 Answer

How can I use iTween to tween the color of a SpriteRenderer? 1 Answer

I can not start, any stopped of itween 1 Answer

Itween, how to mouseclick movement on 3rd person camera 2 Answers


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