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 xandermacleod · May 28, 2013 at 12:51 PM · itweenmultiplepathhash

iTween ValueTo not working

Hi there,

I'm currently using multiple iTween paths to control my camera's location. (C# script).

I have two separate functions that handle different ValueTo commands:

 public float percentageA = 0f;
 public float percentageB = 0f;
 public float EasingSpeedA = 1f;
 public float EasingSpeedB = 1f;
 public GameObject gObjectA;
 public GameObject gObjectB;
 public Transform [] RailA;
 public Transform [] RailB;
 
 void Update()
 {
 iTween.PutOnPath(gObjectA,RailA,percentageA);
 iTween.PutOnPath(gObjectB,RailB,percentageB);
 }
 
 public void SlideATo(float position)
     {
 Debug.Log("B " + position);
     iTween.ValueTo(gObjectA,iTween.Hash("from",percentageA,"to",position,"time",EasingSpeedA,"easetype",iTween.EaseType.easeInOutCubic,"onupdate","SlideAPercentage"));    
     }
     
 void SlideAPercentage(float p)
 {
     percentageA=p;
 }
 
 public void SlideBTo(float position)
     {
 Debug.Log("B " + position);
     iTween.ValueTo(gObjectB,iTween.Hash("from",percentageB,"to",position,"time",EasingSpeedB,"easetype",iTween.EaseType.easeInOutCubic,"onupdate","SlideBPercentage"));    
     }
     
 void SlideBPercentage(float p)
 {
     percentageB=p;
 }

Now in another script I am calling both the SlideATo and SlideBTo functions at different times, and can even get to the point where both Debug.Log messages can be made to appear; however, for some reason I can get 'percentageB' to change using the ValueTo command, but not 'percentageA'.

Can anybody tell me what I might be doing wrong?

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
3
Best Answer

Answer by hiddenspring81 · May 28, 2013 at 02:02 PM

Be careful when setting up callbacks for iTween. Any callbacks for onupdate, onstart, oncomplete, etc. will be invoked on the target GameObject, and not on the script that was setting up the ValueTo tween. For example, the callbacks for

 iTween.ValueTo(gObjectB,iTween.Hash("from",percentageB,"to",position,"time",EasingSpeedB,"easetype",iTween.EaseType.easeInOutCubic,"onupdate","SlideBPercentage"));

Will be invoked on gObjectB, but you callback methods were defined on a script, attached to gameObject. You can override this behavior by supplying the onupdatetarget parameter (there are similarly named parameters for other events too), which will redirect the iTween callback to a GameObject of your choosing. Your code will then become

 iTween.ValueTo(gObjectB,iTween.Hash("from",percentageB,"to",position,"time",EasingSpeedB,"easetype",iTween.EaseType.easeInOutCubic,"onupdate","SlideBPercentage","onupdatetarget",gameObject));

This code is untested, but it should give you an idea about how to solve the problem.

Comment
Add comment · 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

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

14 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

Related Questions

iTween - look for new path, move to or reverse at end? 0 Answers

ITween orienttopath x-y-z? 1 Answer

How do you create random paths in iTween? 0 Answers

how to cancel iTween Catmull-Rom path 1 Answer

iTween even velocity 9 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