Project_WL/Assets/Script/Character/Projectile/Projectile/Projectile_Keepmove.cs

34 lines
924 B
C#

using System.Collections;
using UnityEngine;
public class Projectile_Keepmove : ProjectileBase
{
public override void Set(ProjectileData _data)
{
_data.eStartPos = eProjectileStartPos.Shooter;
transform.localScale = _data.shooter.transform.localScale;
base.Set(_data);
transform.LookAt(_data.target.Get_position());
StartCoroutine(Co_Move());
}
IEnumerator Co_Move()
{
while (m_ProjecTileData.LifeTime > 0f)
{
transform.Translate(m_ProjecTileData.Speed * Time.deltaTime * Vector3.forward);
yield return null;
m_ProjecTileData.LifeTime -= Time.deltaTime;
}
var anim = GetComponent<Animation>();
if (anim != null)
{
anim.Play("die");
yield return new WaitForSeconds(anim["die"].length);
Off();
}
else
Off();
}
}