Itween Use Cases

Source: Internet
Author: User

1. Control the movement of the ball, as well as the parameter settings, the script is mounted on the object to be moved

Using Unityengine;
Using System.Collections;

public class Itweenmovecntrl:monobehaviour
{

void Start ()
{

The parameters used to save the Itween in the form of a key-value pair
Hashtable args = new Hashtable ();

Here is the type of Setup, Itween type and many, in the source of the enumeration Easetype
For example, moving the effects, the first vibration in the move, have retreated in the move, first accelerated in the speed, and so on
Args. ADD ("Easetype", ITween.EaseType.easeInOutExpo);

       //moving speed,
        args. ADD ("Speed", 10f);
       //Move the overall time. If you coexist with speed then priority speed
        args. ADD ("Time", 1f);
       //This is for color processing. Can look at the source of the enumeration.
        args. ADD ("Namedvaluecolor", "_speccolor");
       //Deferred execution time
        args. ADD ("delay", 0.1f);
       //move toward a point in the process
        args. ADD ("Looktarget", Vector3.zero);

Three loop type none Loop Pingpong (General loop back and forth)
Args. ADD ("Looptype", "none");
Args. ADD ("Looptype", "loop");
Args. ADD ("Looptype", "pingpong");

Handles events during the move.
The Animationstart method is called when the move begins, and 5.0 indicates its arguments
Args. ADD ("OnStart", "Animationstart");
Args. ADD ("Onstartparams", 5.0f);
The object that sets the accepted method, which is accepted by default, can also be changed to another object,
Then you have to implement the Animationstart method in the script that receives the object.
Args. ADD ("Onstarttarget", gameobject);

Called at the end of the move, the parameters are similar to the above
Args. ADD ("OnComplete", "animationend");
Args. ADD ("Oncompleteparams", "End");
Args. ADD ("Oncompletetarget", gameobject);

Called in the move, and the parameters are similar to the above
Args. ADD ("OnUpdate", "animationupdate");
Args. ADD ("Onupdatetarget", gameobject);
Args. ADD ("Onupdateparams", true);

X y z indicates the position of the move.

Args. ADD ("X", 5);
Args. Add ("Y", 5);
Args. ADD ("Z", 1);

Of course you can write Vector3.
Args. ADD ("position", Vectoe3.zero);

Finally let the object begin to move
Itween.moveto (Gameobject, args);
}

Called in object Movement
void Animationupdate (bool f)
{
Debug.Log ("UPDATE:" + f);
}
Called when the object starts to move
void Animationstart (float f)
{
Debug.Log ("Start:" + f);
}
Called when an object is moved
void Animationend (string f)
{
Debug.Log ("End:" + f);
}

}

2. Auto-pathfinding, in fact, according to some of the established points to move the object, the script is mounted on the object to be moved

Using Unityengine;
Using System.Collections;

public class Path:monobehaviour {

All points in the path pathfinding
Public Transform [] paths;

void Start ()
{
Hashtable args = new Hashtable ();
Set the point of the path
Args. ADD ("path", paths);
The set type is linear and the linear effect is better.
Args. ADD ("Easetype", iTween.EaseType.linear);
Set the speed of pathfinding
Args. ADD ("Speed", 10f);
Whether to go from the original position to the position of the first point in the path first
Args. ADD ("Movetopath", true);
Do you want the model to always be in the direction of the face target, and the corner will automatically rotate the model
If you find that your model is always in the same direction when you're looking for a path, then be sure to open this.
Args. ADD ("Orienttopath", true);

Let the model begin to find the way
Itween.moveto (Gameobject,args);
}

void Ondrawgizmos ()
{
Draw paths and lines in the scene view
Itween.drawline (Paths,color.yellow);

Itween.drawpath (paths,color.red);

}

}

Itween Use Cases

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.