Skip to content

Instantly share code, notes, and snippets.

Last active Jan 31, 2021
What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class DOTweenTest : MonoBehaviour
// Unity-chan Animator
public Animator animator;
IEnumerator Start ()
transform.localPosition = new Vector3 (0, 0, -5.8f);
// 再生開始
var tw = transform.DOLocalPath (
new Vector3[]
new Vector3 (2.6f, 0, -2f),
4f, PathType.CatmullRom)
.SetLookAt (0.3f, Vector3.forward)
.SetEase (Ease.Linear);
animator.SetFloat ("Speed", 1f);
yield return new WaitForSeconds (3f);
// Animator, Tween共に巻き戻し
animator.SetFloat ("Speed", -1f);
tw.PlayBackwards ();
yield return new WaitForSeconds (3f);
// Animator, Tween共に2倍速
animator.SetFloat ("Speed", 2f);
tw.PlayForward ();
tw.timeScale = 2f;
// Tweenの終了を待機
yield return tw.WaitForCompletion ();
// Animator, Tween共にスピードを元に戻す
animator.SetFloat ("Speed", 1f);
tw.timeScale = 1f;
animator.SetTrigger ("Idle");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment