Ln Go

BossRock 본문

Unity/Quad Action

BossRock

Ln Ro 2021. 6. 4. 02:20
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BossRock : Bullet
{
    Rigidbody rigid;

    float angularPower = 2;
    float scaleValue = 0.1f;
    bool isShoot;

    void Awake()
    {
        rigid = GetComponent<Rigidbody>();
        StartCoroutine(GainPowerTimer());
        StartCoroutine(GainPower());
    }

    IEnumerator GainPowerTimer()
    {
        yield return new WaitForSeconds(2.2f);
        isShoot = true;
    }
    IEnumerator GainPower()
    {
        while (!isShoot)
        {
            angularPower += 0.02f;
            scaleValue += 0.005f;
            transform.localScale = Vector3.one * scaleValue;
            rigid.AddTorque(transform.right * angularPower, ForceMode.Acceleration);

            //While문에는 꼭 yield return null 포함 
            yield return null;
        }
    }
}

'Unity > Quad Action' 카테고리의 다른 글

Weapon  (0) 2021.06.04
BossMissile  (0) 2021.06.04
Boss  (0) 2021.06.04
Enemy  (0) 2021.06.04
Player  (0) 2021.06.04
Comments