1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UnityのDOTweenで無限ループをKillしたりStartしなおすと不自然になっちゃう?

Posted at

DOTween便利ですよね。

tweener.SetLoops(-1) すると無限ループできるわけですが、
この時、ループしてるtweenのプロパティを再設定したいなとか思うじゃないですか。

var duration = 1f;
var tweener = transform.DORotate(new Vector3(0,0,-359.9f), duration).SetLoops(-1).Play();

tweener.Kill();
duration = 2f;
tweener = transform.DORotate(new Vector3(0,0,-359.9f), duration).SetLoops(-1).Play();

なんか無限ループのつなぎ目がうまく繋がらなくなる…!

のは、tweenerをkillしたからと言って、プロパティはリセットされないからでした。

var duration = 1f;
var tweener = transform.DORotate(new Vector3(0,0,-359.9f), duration).SetLoops(-1).Play();

tweener.Kill();

// reset property
transform.localRotation = Quaternion.Euler(0, 0, 0);

duration = 2f;
tweener = transform.DORotate(new Vector3(0,0,-359.9f), duration).SetLoops(-1).Play();
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?