-
Basically, my hero will do some stuffs like slashing the melon, but the collision doesn’t work. It just passed through the melon (image below):
-
I configured the components needed.
Tag = watermelonTag
Is Trigger = checked
-
I place this code in my Hero game object.
void OnCollisionEnter2D (Collision2D collision){
switch (collision.gameObject.tag){
case "watermelonTag":
srSlash.sprite = slashingSprite;
audio.PlayOneShot(swordSound);
audio.PlayOneShot(fruitSmashing);
Destroy(collider.gameObject);
break;
case "pineappleTag":
srSlash.sprite = slashingSprite;
audio.PlayOneShot(swordSound);
audio.PlayOneShot(fruitSmashing);
Destroy(collider.gameObject);
break;
Thanks :))