I usually try to figure things out on my own but I’m stumped. I have a left, right and down arrow in my UI touch controls. The left and right buttons are working great. I cannot for the life of me figure how to code my down arrow to represent what essentially is the (“s”), (“↓”) on the keyboard. Any ideas on how to code this would be greatly appreciated.
Well, the way I always handle having controls work on both mobile and in the editor (or standalone win/mac) is to do something where I look for input in the editor over an update (checking if a key is down, or an axis) but when using the UI to do things on mobile, you need to check instead for events of the button, like OnPointerDown and OnPointerUp to keep track of the user tapping and holding the UI button down. (read more on that here) and then have it do the exact same things while that input is held down.
So what exactly is going wrong with the code you think? Is the down arrow functionality just not working? How far through the code does it seem to get? Is moveDown being set true when the UI button is held down? Is it being set false when it is let go? Does it work normally when your doing this with the WASD keys?
Yes my moveDown bool is set to true when holding down on the UI button and set to false when let go.
Sorry if there are gaps in explaining what I’m trying to do but basically I wrote a script to disable the 2D collider on any platform so I can press down and go through it and once through the platform it re-enable the 2D collider. Now this works using the S and down arrow perfectly on my keyboard but I can’t seem to figure out how to use my UI down button to accomplish this task.
Wheres the code where it worked on PC (well, on keyboard)? I mean like a snippet of the part that does what you need it to do, when you press S or down arrow. Sorry to make you work for it haha, but I just am trying to figure out exactly where things are going wrong!