Commit 5ac2d7cd authored by 18김상언's avatar 18김상언

활 조준할때 화살 날아갈 위치 지정하게 바뀌었음.

근데 약간 화살 생성되는 시점이 애니메이션이랑 살짝 안맞는거 같음.
수치는 나중에 다 합치고 조절합시다. ㅇㅈ? ㅇ ㅇㅈ~
parent 517ee9bc
...@@ -79,8 +79,11 @@ public class ArcherTrack : StateMachineBehaviour ...@@ -79,8 +79,11 @@ public class ArcherTrack : StateMachineBehaviour
IEnumerator WaitforShot() IEnumerator WaitforShot()
{ {
yield return new WaitForSeconds(0.75f); yield return new WaitForSeconds(0.25f);
Vector2 direction = enemy.transform.GetChild(0).position - player.transform.position; Vector2 direction = enemy.transform.GetChild(0).position - player.transform.position;
yield return new WaitForSeconds(0.5f);
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward); Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
Instantiate(enemy_arrow, enemy.transform.GetChild(0).position, rotation); Instantiate(enemy_arrow, enemy.transform.GetChild(0).position, rotation);
......
...@@ -13,15 +13,19 @@ public class EnemyArrow : MonoBehaviour ...@@ -13,15 +13,19 @@ public class EnemyArrow : MonoBehaviour
public LayerMask stopLayer; public LayerMask stopLayer;
Rigidbody2D rb; Rigidbody2D rb;
Player target; Player target;
Vector2 moveDirection; Vector3 moveDirection;
Vector2 changeAngle;
void Start() void Start()
{ {
rb = GetComponent<Rigidbody2D>(); rb = GetComponent<Rigidbody2D>();
target = GameObject.FindObjectOfType<Player>(); target = GameObject.FindObjectOfType<Player>();
moveDirection = (target.transform.position - transform.position).normalized * moveSpeed; moveDirection = transform.rotation.eulerAngles;
rb.velocity = new Vector2(moveDirection.x, moveDirection.y);
rb.velocity = -moveSpeed *new Vector2(Mathf.Cos(Mathf.Deg2Rad * moveDirection.z), Mathf.Sin(Mathf.Deg2Rad * moveDirection.z));
} }
/* void FixedUpdate() /* void FixedUpdate()
...@@ -59,5 +63,6 @@ public class EnemyArrow : MonoBehaviour ...@@ -59,5 +63,6 @@ public class EnemyArrow : MonoBehaviour
yield return new WaitForSeconds(time); yield return new WaitForSeconds(time);
Destroy(gameObject); Destroy(gameObject);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment