Page 371 - MDP2022-3
P. 371
bullet.transform.position = transform.position;
Rigidbody2D rigid = bullet.GetComponent<Rigidbody2D>();
Vector3 dirVec = Player.transform.position - transform.position;
rigid.AddForce(dirVec.normalized * 5, ForceMode2D.Impulse);
}else if(enemyName == "C")
{
GameObject bulletR = objectManager.MakeObj("bulletEnemyA");
bulletR.transform.position=transform.position + Vector3.right * 0.2f;
GameObject bulletL = objectManager.MakeObj("bulletEnemyA");
bulletL.transform.position = transform.position + Vector3.left * 0.2f;
Rigidbody2D rigidR = bulletR.GetComponent<Rigidbody2D>();
Rigidbody2D rigidL = bulletL.GetComponent<Rigidbody2D>();
Vector3 dirVecR = Player.transform.position - (transform.position +
Vector3.right * 0.3f);
Vector3 dirVecL = Player.transform.position - (transform.position +
Vector3.left * 0.3f);
rigidR.AddForce(dirVecR.normalized * 5, ForceMode2D.Impulse);
rigidL.AddForce(dirVecL.normalized * 5, ForceMode2D.Impulse);
}
curshortDelay = 0;
}
}
void Relode() //딜레이 확인
{
curshortDelay += Time.deltaTime;
}
void OnEnable()
{
switch (enemyName)
{
case "A":
health = 3;
break;
case "B":