public new void Update() { base.Update(); switch (state) { case PopeState.Moving: setAngle(); body.AddForce(transform.right * moveForce); break; case PopeState.Attacking: if (target.dead) { state = PopeState.Moving; } attackCooldown -= Time.deltaTime; if (attackCooldown <= 0) { target.takeDamage(5); attackCooldown = 2f; } break; } body.velocity = body.velocity * 0.9f; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Attackable")) { target = collision.gameObject.GetComponent <Attackable>(); state = PopeState.Attacking; } }
public new void Start() { base.Start(); state = PopeState.Moving; }