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
1
Question by Jason Hamilton · Jun 28, 2010 at 04:33 AM · animationitween

On end of iTween

Is it possible to have something happen when this iTween ends:

function Start ()
{
    iTween.moveTo( gameObject, { "x" : -1449.818 , "y" : 398.2629 , "z" : 1201.911 , "time" : Speed });
}

if it is how do I go about it

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

3 Replies

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

Answer by Tetrad · Jun 28, 2010 at 05:55 AM

http://itween.pixelplacement.com/ look at "Callback Functions"

Nearly all of the methods in iTween allow the addition of an optional "onStart" and "onComplete" argument. This argument takes a string refrence to an existing function in any script attached to the currently utilized GameObject. In addition, you can optionally provide "onStartParams" and/or "onCompleteParams" arguments to allow the passing of an object to the destination "onStart" or "onComplete" function. You can also specify an "onStartTarget" and/or "onCompleteTarget" to allow the firing of a function on a different GameObject.

To illustrate this functionality let's create a looping animation (Note: iTween includes a native loop feature called "loopType" built in which could have been set to "pingPong" to do this in 1 line of code but this example is merely to demonstrate the flexibility of utilizing callbacks):

private var tweenTarget : GameObject; var counter : GUIText; var count : int =0;

function Start(){ tweenTarget=gameObject; roll("right"); counter.guiText.material.color = Color.black; }

private function roll(direction: String): void{ switch(direction){ case "right": iTween.rotateBy(tweenTarget,{"z":-.5}); iTween.moveTo(tweenTarget,{"x":1.7, "onComplete":"roll", "onCompleteParams":"left"}); count+=1; break;

     case "left":
     iTween.rotateBy(tweenTarget,{"z":1});
     iTween.moveTo(tweenTarget,{"x":-1.7, "onComplete":"roll", "onCompleteParams":"right"});
     count+=1;
     break;
 }

 counter.text=count.ToString() + " Loops";

}

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
avatar image
1
Best Answer

Answer by qJake · Jun 28, 2010 at 05:07 AM

Reference: http://www.insquare.com/itween/

I think you can just layer them on top of each other, and they'll queue automatically. It's kinda weird, but it's easier than sticking it in a coroutine or something. Like this:

function Start ()
{
    iTween.moveTo( gameObject, { "x" : -1449.818 , "y" : 398.2629 , "z" : 1201.911 , "time" : Speed });
    iTween.moveTo( gameObject, { "x" : 0 , "y" : 0 , "z" : 0 , "time" : Speed });
}
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 Jason Hamilton · Jun 28, 2010 at 05:31 AM 0
Share

yea, but what if I wont to say, Delete the object once its done? sorry I should have been more clearer in the question. :)

avatar image qJake · Jun 28, 2010 at 06:22 AM 0
Share

Yes, you should have. Look at the "Callback Functions" section of the iTween webpage, it describes how you can do that.

avatar image
0

Answer by dentedpixel · Dec 17, 2012 at 07:45 PM

This is how you would accomplish the same task with LeanTween:

 function Start ()
 {
     var toPoint = Vector3( -1449.818, 398.2629, 1201.911);
     var speed = 1.0;
     LeanTween.move( gameObject, toPoint, speed, {"onComplete":moveComplete});
 }
 
 function moveComplete(){
     Debug.Log("I am done!");
 }


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

1 Person is following this question.

avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Update iTween Path at Runtime 1 Answer

iTween Get the path from object nodes and move the object at same speed by loop 1 Answer

Is it possible to manipulate Mecanim state machine / blend trees from scripting? 0 Answers

No movement when animation plays (2d) 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