게임개발/게임플랫폼 응용 프로그래밍

데미지 텍스트 만들기 2 : DoTween으로 만들기

pudding81 2024. 3. 11. 16:25

using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Damage2 : MonoBehaviour
{
        
    void Start()
    {
        //위로 200픽셀 움직임
        var targetPos = this.transform.localPosition;
        targetPos.y += 200;
        this.transform.DOLocalMoveY(targetPos.y, 1).OnComplete(() =>
        {
          Destroy(this.gameObject);
        });

        //크기가 2배로 커졌다가 작아짐
        this.transform.DOScale(2, 0.5f).OnComplete(() =>
        {
            if(this.gameObject != null)
            {
                this.transform.DOScale(0.1f, 0.5f);
            }         
        });


    }

    
    void Update()
    {
        
    }
}

// Let's move the red cube TO 0,4,0 in 2 seconds
redCube.DOMove(new Vector3(0,4,0), 2);

// Let's move the green cube FROM 0,4,0 in 2 seconds
greenCube.DOMove(new Vector3(0,4,0), 2).From();

// Let's move the blue cube BY 0,4,0 in 2 seconds
blueCube.DOMove(new Vector3(0,4,0), 2).SetRelative();

// Let's move the purple cube BY 6,0,0 in 2 seconds
// and also change its color to yellow.
// To change its color, we'll have to use its material as a target (instead than its transform).
purpleCube.DOMove(new Vector3(6,0,0), 2).SetRelative();
// Also, let's set the color tween to loop infinitely forward and backwards
purpleCube.GetComponent<Renderer>().material.DOColor(Color.yellow, 2).SetLoops(-1, LoopType.Yoyo);