using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cshEnemy : MonoBehaviour
{
public float twoSecond = 2.0f; // 2초 간격
public float passTime = 0.0f; // 몇 초가 흘렀는지 누적 시간. 현재 시간
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
this.transform.Rotate(0.0f, 90.0f * Time.deltaTime, 0.0f); // 일정한 속도로 y축을 중심으로 회전
if (passTime >= twoSecond) // 현재 시간이 2초가 지났으면
{
GetComponent<Rigidbody>().AddForce(Vector3.up * 300 * Time.deltaTime); // 위 방향으로 힘을 추가
passTime = 0.0f; // 시간을 0으로 세팅
}
else
{
passTime += Time.deltaTime;
}
}
}
반응형