How to play sound when bouncing off mushroom

With the mushroom sprites being on the Bouncing Tilemap, how can I trigger a sound when the player bounces on them? I have a mushroom tile and a mushroom sprite on the Bouncing Tilemap but can’t figure out a way to register a collision/onTriggerEnter2d type event.

1 Like

Hi Michael,

The Bouncing Tilemap has got a collider attached, hasn’t it? If it is a non-trigger collider, OnCollisionEnter2D or OnCollisionExit2D could work.

Instead of adding the code to the player, you could create a new thread and attach it to the Bouncing Tilemap collider (= the game object with the Tilemap collider). This way, you won’t have to check who/what collided with this tilemap collider because it is always the player.

Start with logging a message into your console to see if the player “enters” or “exists” the bouncing tilemap collider.

1 Like

Hi Nina, thank you for the quick response! Your answer helped me better understand tile maps. Also, once I hid all the other tilemaps and had the Bouncing Tilemap only, I could easily see the colliders around the mushroom sprites.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms