public void Attack(float angle, float force, bool reverse) { var shotTransform = Instantiate(shotPrefab) as Transform; // Assign position shotTransform.position = transform.position; float x = force * (90 - angle) / 90; float y = force * angle / 90; // The is enemy property DrugScript shot = shotTransform.gameObject.GetComponent <DrugScript>(); Rigidbody2D rb = shot.GetComponent <Rigidbody2D>(); if (rb != null) { if (!reverse) { rb.AddForce(new Vector2(x, y)); } else { rb.AddForce(new Vector2(-x, y)); } } }
private void OnTriggerEnter2D(Collider2D collision) { DrugScript dr = collision.transform.GetComponent <DrugScript>(); if (dr != null) { Destroy(this.gameObject); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.name == "VirusStopper") { stop = true; stopPos = this.transform.position; } DrugScript dr = collision.transform.GetComponent <DrugScript>(); if (dr != null) { Destroy(this.gameObject); } }