So in my project I have 3 different parents in the scene called ‘All’. Each parent has their corresponding sound entity. When keyboard is enabled the five buttons on the right work. Which means when they are clicked the sound that was playing before stops and the corresponding sound plays. However using the same buttons, same sound and same script this does not work when the drums and guitar parent is enabled.
When the script runs it will search for the first entity named RockSound. That will always be the RockSound entity under keyboard_Parent parent entity.
FindByName() returns the first entity found in the hierarchy by that name.
To fix that you will have to create variations of that script, that search under the right parent.
@yaustar we would have considered this, but @Krish_USCan has recently started playcanvas scripting, and I am busy with the other parts of the app. For sure, it’s an elegant solution, but I think @Leonidas’s idea is a bit easier to grasp for @Krish_USCan.