- Home /
How can I get my UI Buttons to work when moving horizontal
So I'm making a mobile platformer game as a school project and at the moment I'm making UI buttons that would control the player's actions so you don't need a keyboard obviously. So far I've made so that if I press the keys or press the buttons to jump or shoot, player executes the action so it shoots or jumps. Now I'm trying to make so that the player would also move with the buttons on-screen, but it doesn't seem to work.
So in the picture above I have some code which says as an example that if I press W on the keyboard or press the button I have in my game screen for jumping, my player jumps. Same thing for the shooting. Here I have my code I'm working on so that my player would move left or right. I thought that putting the bLeft.GetButtonPressed would work with the myRigibody things under it since it works with the keyboard keys, but it doesn't. I'm just a beginner with Unity stuff since this is my first project with it and I have experience close to none with this kind of stuff so everything that might help is very appreciated :).