Quantcast
Channel: Questions in topic: "left"
Viewing all articles
Browse latest Browse all 135

from keyboard inputs to UI buttons,

$
0
0
Hello I am trying to switch from left arrow right arrow inputs for pc, to on screen UI buttons for andoid I followed few tutorials and few answers here but I did not find a valid solution. the player moves inside the rectangular screen, like we see everything from top. I have the player that moves forward constantly and I add torque to the RB2D to make it rotate left and right while going forward and it works fine. transform.Translate(0, speed * Time.deltaTime, 0); if (Input.GetKey(KeyCode.LeftArrow)) transform.Rotate(0, 0, torqueAmount); if (Input.GetKey(KeyCode.RightArrow)) transform.Rotate(0, 0, -torqueAmount); then I added two UI buttons on the screen, one for left and one for right , I added to the player movement script two methods going left and going right where i copied the transform.Rotate part but I think it does not work because they are not in the update right? I followed a tutorial of a guy that uses crossplatforminput but the buttons do not respond to the commands if (CrossPlatformInputManager.GetButtonDown("L")) { transform.Rotate(0, 0, torqueAmount); } if (CrossPlatformInputManager.GetButtonDown("R")) { transform.Rotate(0, 0, -torqueAmount); What am I missing in the logic ? or how can i put in the update the movement? I am a bit lost Thank you very much if you got an advise to give me

Viewing all articles
Browse latest Browse all 135

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>