Академический Документы
Профессиональный Документы
Культура Документы
Store (/catalog) Blog (/blog) Sell Assets (/sell) About us (/about-us) Contacts (/contacts) Login (/login) Sign up (/register)
SEARCH
Categories
Basic animation iTween
Games (/blog/category/game
Let's try to simulate a small area for our tests. Tutorials (/blog/category/tut
First of all, connect iTween-package from the Asset store: https://www.assetstore.unity3d.com/en/ (/redirect?
url=https%3A%2F%2Fwww.assetstore.unity3d.com%2Fen%2F) , we should see something something like that: Unity (/blog/category/unity)
Archives
2019
2018
2016
2014
Cube - is the object that we are going to animate. Now we move on iTween. Create a new script component type C #
at our facility. Fill method Start:
https://unionassets.com/blog/basic-animation-itween-259 1/5
18/04/2019 Basic animation iTween | Blog | Union Assets - Dev Assets Marketplace
void Start()
{
iTween.RotateFrom(gameObject, iTween.Hash("y", 90.0f, "time", 2.0f, "easetype",
iTween.EaseType.easeInExpo));
iTween.MoveFrom(gameObject, iTween.Hash("y", 3.5f, "time", 2.0f, "easetype",
iTween.EaseType.easeInExpo));
iTween.ShakePosition(Camera.main.gameObject, iTween.Hash("y", 0.3f, "time", 0.8f, "delay",
2.0f));
iTween.ColorTo(gameObject, iTween.Hash("r", 1.0f, "g", 0.5f, "b", 0.4f, "delay", 1.5f, "time",
0.3f));
iTween.ScaleTo(gameObject, iTween.Hash("y", 1.75f, "delay", 2.8f, "time", 2.0f));
iTween.RotateBy(gameObject, iTween.Hash("x", 0.5f, "delay", 4.4f));
iTween.MoveTo(gameObject, iTween.Hash("y", 1.5f, "delay", 5.8f));
iTween.MoveTo(gameObject, iTween.Hash("y", 0.5f, "delay", 7.0f, "easetype",
iTween.EaseType.easeInExpo));
iTween.ScaleTo(gameObject, iTween.Hash("y", 1.0f, "delay", 7.0f));
iTween.ShakePosition(Camera.main.gameObject, iTween.Hash("y", 0.3f, "time", 0.8f, "delay",
8.0f));
iTween.ColorTo(gameObject, iTween.Hash("r", 0.165f, "g", 0.498f, "b", 0.729f, "delay", 8.5f,
"time", 0.5f));
iTween.CameraFadeAdd();
iTween.CameraFadeTo(iTween.Hash("amount", 1.0f, "time", 2.0f, "delay", 10.0f));
}
Method RotateFrom used to rotate an object. Unlike RotateTo and RotateBy, RotateFrom used to initialize the
specified rotation angle and rotate to their original condition. Method, like most others, has an overload. You can use
a short or long version:
We pass gameObject - an object that is the current script. In order not to write something like:
https://unionassets.com/blog/basic-animation-itween-259 2/5
18/04/2019 Basic animation iTween | Blog | Union Assets - Dev Assets Marketplace
We use iTween.Hash - Express version of Hashtable. As we pointed arguments y = 90.0f, is equivalent (if x and z are
zero, of course)
time=2.0f
Time that should be spent for animation. There are similar argument called "speed", in his case does not indicate the
time, but
the rate at which the animation will be held. The last argument, which we pointed it easetype =
iTween.EaseType.easeInExpo. easetype waveform is to be used for interpolation. Here is a graphical representation
of curves:
Move From similar to the previous one, it should be understood simply used instead of the rotation movement.
ShakePosition used in this case in order to implement the "shaking" the camera. This method makes you move an
object by decreasing amplitude, does not use interpolation, the object will appear at random points in the designated
part of him. There is a new argument called "delay", it is quite important option animation is used to specify the
number of seconds that must elapse before the start of the animation.
iTween.ColorTo(gameObject, iTween.Hash("r", 1.0f, "g", 0.5f, "b", 0.4f, "delay", 1.5f, "time", 0.3f));
https://unionassets.com/blog/basic-animation-itween-259 3/5
18/04/2019 Basic animation iTween | Blog | Union Assets - Dev Assets Marketplace
RotateBy reminds RotateFrom, necessary in cases where the object you want to deploy more than 360 degrees
(although in this case we could have done by RotateTo). Suppose we have indicated z = 2.0f, it would mean that the
object must turn twice around the Z axis for a certain period of time.
MoveTo, probably, the main method of the whole class iTween. He moves the object to the specified coordinates in
the allotted time. The interpolation is based on all the same easetype, which you already know.
iTween.CameraFadeAdd();
iTween.CameraFadeTo(iTween.Hash("amount", 1.0f, "time", 2.0f, "delay", 10.0f));
CameraFadeAdd creates a new object that is used to simulate the blackout. The depth varies from the current value
of the specified arguments. The following overload:
CameraFadeAdd()
CameraFadeAdd(Texture2D texture)
CameraFadeAdd(Texture2D texture, int depth)
void Awake()
{
style = new GUIStyle();
style.fontSize = 60;
}
void Start()
{
iTween.MoveTo(gameObject, iTween.Hash("position", new Vector3(5.0f, 1.0f, 0.0f), "oncomplete",
"myClbk",
"loopType", iTween.LoopType.loop, "speed", 2.0f));
}
void myClbk()
{
clbkN++;
}
void OnGUI()
{
GUI.Label(new Rect(10, 10, 0, 0), "Callback # "+clbkN, style);
}
}
https://unionassets.com/blog/basic-animation-itween-259 4/5
18/04/2019 Basic animation iTween | Blog | Union Assets - Dev Assets Marketplace
oncomplete = "myClbk"
At the end of the animation (or iteration of the loop animation) method is called with the specified name.
loopType = iTween.LoopType.loop
Type animation. In this case, indicate the normal cycle, the animation will be played endlessly, at the beginning of
each animation object will be moved to the starting position.
All data posted on the site represents accessible information that can be browsed and downloaded for free from the
web.
https://habrahabr.ru/post/220837/
27 Nov 2014
Posted by: Volodymyr Sapaiev (/user/reboot)
User replies
No replies yet
Submission Guidelines
(/page/submission-guidelines)
https://unionassets.com/blog/basic-animation-itween-259 5/5