(Unity)ドッスンぽい挙動の作成

(スクリプト)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Dossunn : MonoBehaviour
{
    private Vector3 pos;

    private void Start()
    {
        pos = transform.position;

        StartCoroutine(D_Controller());
    }

    private IEnumerator D_Controller()
    {
        yield return new WaitForSeconds(2f);

        while (true)
        {
            for (int i = 0; i < 50; i++)
            {
                pos.y += 0.1f;
                transform.position = pos;

                yield return new WaitForSeconds(0.01f);
            }

            yield return new WaitForSeconds(2f);

            for (int i = 0; i < 10; i++)
            {
                pos.y -= 0.5f;
                transform.position = pos;

                yield return new WaitForSeconds(0.01f);
            }

            yield return new WaitForSeconds(1f);
        }
    }
}