LoginSignup
0
1

More than 1 year has passed since last update.

UnityのDOTweenでTweenを逆再生する方法

Posted at

DOTweenはUnityで使えるアセットの一つです。
読み方は「ドットゥィーン」らしいです。

Pro版もあります。違いはエディター拡張やパスで座標を指定できるようになったりします。

本題に入ります。
DOTweenPathを使った場合の逆再生の方法についてです。

DOTweenで通常の再生をする場合はDOPlay、DOPlayForward、DORestartなどを使い、
逆再生をするにはDOPlayBackwardsを使います。
が、下記のようにしても逆再生がされません。

public DOTweenPath tweenPath;
void Func()
{
    tweenPath.DOPlayBackwards();
}

これはTweenが最初のパスにある状態から逆再生が開始されるためで、0番目のパスから0番目のパスに移動をしているため、動かないように見えます。

最後のパスから逆再生をするには、以下のようにします。

public DOTweenPath tweenPath;
void Func()
{
    tweenPath.tween.GotoWaypoint(tweenPath.wps.Count);
    tweenPath.DOPlayBackwards();
}

tweenPath.tween.GotoWaypoint(tweenPath.wps.Count);
とすることで、Tweenを最後のパスの地点まで進行させることができ、そこから逆再生が開始されるようになります。
ただし、Completeの処理が呼ばれなかったり、Delayが無視されたりするので、そのあたりは注意が必要です。

0
1
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
0
1