private void OnTriggerEnter2D(Collider2D collision) { if (startDelay <= 0 && collision.CompareTag("BumpBerryPlant")) { BerryPlantController bc = collision.GetComponent <BerryPlantController>(); if (!bc || !bc.canPick) { return; } bc.pickCallback.Invoke(ScriptableObject.CreateInstance <HitBox>()); bounceCallback?.Invoke(); Vector2 bumpDir = new Vector2(1.0f, 2.0f); rb.velocity = Vector2.zero; rb.AddForce(Vector3.Scale(bc.getDir(), bumpDir * 150.0f)); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Enemy")) { Boom(); return; } if (collision.CompareTag("WooshBerryPlant")) { BerryPlantController bc = collision.GetComponent <BerryPlantController>(); if (!bc || !bc.canPick) { return; } BeginWoosh(bc.center, collision.transform.GetComponent <BerryPlantController>().getForward()); collision.GetComponent <BerryPlantController>().pickCallback.Invoke(ScriptableObject.CreateInstance <HitBox>()); } if (collision.CompareTag("AllyHitbox")) { AllyHitBoxController hbc = collision.GetComponent <AllyHitBoxController>(); if (hbc.hasHit) { return; } hbc.hasHit = true; HitBox hb = hbc.hitbox; if (flying) { returnToRigidbody(); } if (hb.interactBroom) { float dx = Vector3.Distance(gameManager.Instance.player.transform.position, transform.position); rb.velocity = Vector2.zero; rb.AddForce(Vector2.Scale(new Vector2(1.25f, 1), hb.kbDir) * 150); } } }