How do I Trigger different music using UID?

0 favourites
  • 6 posts
From the Asset Store
This music pack covers differents situations for visual novels, anime games and many more!
  • I'm working on a Metroidvania style game in only 1 layout and I'm having a hard time to trigger the music in a specific room.

    I'm using the UID for the room transition and saving stuff.

    Here's my code, maybe someone can help me to set up the music per RoomZoneUID.

    Cheers,

    Tagged:

  • That looks fine but if you are constantly overlapping a room zone it will keep trying to play the music and you won't hear anything. Try adding a trigger once or a trigger event such as on collision with room zone.

  • plinkie is correct.

    But you also need to stop any current music playing. Otherwise you're going to get multiple music tracks playing at the same time. So keep careful track of your tags.

  • Thank you so much and Fib!

    I've managed to do what you said.

    And I think it's working fine. Here's the file that I did.

    drive.google.com/drive/folders/1DjrwDK9nTzeQ4S1vdWJfFNlC3_iyxT36

    Just let me know if you have better suggestions.

    Cheers!

  • In general you should never manually type in the UID of an object when using Pick by UID. Imagine for some reason you need to delete a RoomZone during runtime, and then re-add it into the game. The UID will be different after you recreate it

    Instead, you can use an instance variable called "zone" or something, and do:

    RoomZone zone = "garden" ? play garden

    Roomzone zone = "forest" ? play forest

    This way you can assign any RoomZones the appropriate "zone" variable and they will work

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Wow! I've tried it and yes it works and much better because I can easily track the roomZones and replace it without any hassle. Thanks man!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)