I have on screen buttons which are not currently working because there is collider behind them which is flooring for my platformer. Do you know of a possible work around for this issue.
I have stated before that you have to change the transform.position.z value of one of your sprites so that 1 of the sprites don’t overlap eachother in 3d space. This time I have added some pictures with instructions to explain how it works.
You can clearly see in the first picture that in the game scene, the green button is infront of the black sprite. But this is not the case in 3d space, in 3d space the black sprite is actually infront of the green button. In the game scene we only changed the order layer to let it seem like it was infront of the black sprite, while this was not the case.
Now when we change that transform.position.z value to something else. In my case the black sprite Z position was -2 while the GreenButton Z position was 0. So I changed the blacksprite Z position to 1 or higher. Now the Black sprite is actually standing behind the greenbutton in 3d space.
You could also change the button Z position to let it come infront of the black sprite, the same principles are used as above.
Now when I changed the Z position value and click on the button, I would see a value (which I set with GuiText ToString(). This indicates that it worked.
I would use a Canvas and the UI Buttons, because they come with their own built in function OnClick() in the editor. If you want the button to stay in one place in the scene, you would select ‘World Space’ in the Render Mode box.
Thanks this helped me! I was trying to play with the layers but forgot to look at the z location