Page 363 - MDP2022-3
P. 363
if ((isTouchTop && v == 1) || (isTouchBottom && v == -1)||!isControl)
v = 0;
Vector3 curPos = transform.position;
Vector3 nextPos = new Vector3(h, v, 0) * speed * Time.deltaTime;
transform.position = curPos + nextPos;
if (Input.GetButtonDown("Horizontal") || Input.GetButtonUp("Horizontal"))
{
anim.SetInteger("Input", (int)h);
}
}
void OnTriggerEnter2D(Collider2D collision) //플레이어 상호작용
{
if (collision.gameObject.tag == "Border") //경계선 설정
{
switch (collision.gameObject.name)
{
case "Top":
isTouchTop = true;
break;
case "Bottom":
isTouchBottom = true;
break;
case "Right":
isTouchRight = true;
break;
case "Left":
isTouchLeft = true;
break;
}
}else if(collision.gameObject.tag=="Enemy"|| collision.gameObject.tag ==
"EnemyBullet") //적 혹은 적이 발사한 탄환과의 상호작용
{
if (isReSpawnTime)
return;
if (!isHit)
{
return;
}
isHit = false;
life -= 1;