LoginSignup
4
0

More than 5 years have passed since last update.

UnityのiTweenを試してみる その5 Punch系

Last updated at Posted at 2018-05-18

株式会社ZOOA(ゾーア)のzobです。[@twitter]

弊社はフリーランスや、個人事業主、給料UPを目指している方向けに高単価求人案件配信サイト(ZOB)も運営しておりますので是非ご覧ください!

前回に引き続き、iTweenを色々と試してみました。

iTween

今回はPunch系のメソッドを試してみました。

検証で使用したUnityバージョンは以下の通りです。
Unity2018.1.0f2

Punch系メソッド

Punch系メソッドは、ゆらゆらと揺らすようなアニメーションをすることができます。
一度ひっぱって元に戻る、バネのようなイメージです。

iTween.PunchPosition

PunchPositionは指定した座標位置に一度移動後、ゆらゆらと揺れながら元の座標に戻ります。

iTween.PunchPosition(gameObject, iTween.Hash("x", 3f));

image.gif

値はX,Y,Zの3つを指定できます。

iTween.PunchPosition(gameObject, iTween.Hash("x", 3f, "y", 3f, "z", 3f));

X,Y,Zは一つしか指定できないようです。以下のように複数指定するとエラーが発生します。

iTween.PunchPosition(gameObject, iTween.Hash("x", 3f, "x", 5f));

Add系のように、連続でアニメーションさせることが可能のようです。
以下のサンプルコードを試してみます。

iTween.PunchPosition(gameObject, iTween.Hash("x", 3f, "time", 3f));
iTween.PunchPosition(gameObject, iTween.Hash("y", 3f, "time", 3f, "delay", 0.5f));

image.gif

iTween.PunchPosition

PunchPositionは指定した角度に一度移動後、ゆらゆらと揺れながら元の角度に戻ります。

iTween.PunchRotation(gameObject, iTween.Hash("z", 360f));

image.gif

値はX,Y,Zの3つを指定できます。

iTween.PunchRotation(gameObject, iTween.Hash("x", 360f, "y", 360f, "z", 360f));

Add系のように、連続でアニメーションさせることが可能のようです。
以下のサンプルコードを試してみます。

iTween.PunchRotation(gameObject, iTween.Hash("z", 360f, "time", 3f));
iTween.PunchRotation(gameObject, iTween.Hash("y", 360f, "time", 3f, "delay", 0.5f));

image.gif

iTween.PunchScale

PunchScaleは指定した値に拡大・縮小後、ゆらゆらと揺れながら元の大きさに戻ります。

iTween.PunchScale(gameObject, iTween.Hash("x", 5f, "time", 3f));

image.gif

値はX,Y,Zの3つを指定できます。

iTween.PunchScale(gameObject, iTween.Hash("x", 3f, "y", 3f, "z", 3f));

Add系のように、連続でアニメーションさせることが可能のようです。
以下のサンプルコードを試してみます。

iTween.ShakeScale(gameObject, iTween.Hash("x", 3f, "time", 3f));
iTween.ShakeScale(gameObject, iTween.Hash("x", 3f, "y", 3f, "time", 3f, "delay", 1.5f));

image.gif

まとめ

Punch系を一通り試してみました。
バネのような動きがメソッド一つで実現できました。色々な表現に使えそうです!
次回もiTweenの検証結果を書いていきます!

・技術検証協力 荻野雄季(Twitter, Qiita)


UnityのiTweenを試してみる
その1 Move系
その2 Rotate系
その3 Scale系
その4 Shake系
その5 Punch系←今ココ


株式会社ZOOA(ゾーア)
弊社はフリーランスや、個人事業主に特化したSES案件共有サイト(ZOB)も運営しておりますので給料UPを目指している方は是非こちらもご覧ください!


4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0