- Home /
Touch GUITexture and Game object moves left or right, how can i do that?
I have modified the Sidescroll Control script from the mobile asset in Unity, and I created three GUITexture buttons a left touch pad and a right touch pad and a jumptouchpad, They all are doing what they suppose to, my problem is getting the left and right touch pads to respond on touch NOT when I touch and drag my finger left or right, I have been modifying this code and searching the forums for a while and my last resort is to ask a question, I can do with some help! I have placed a snippet of code i edited for the left and right touch pad buttons. The code that is commented out was the original. they all use the Joystick script from the mobile assets in unity! Where am i Going WRONG!
var movement = Vector3.zero;
// Apply movement from move joystick
//if ( moveTouchPad.position.x > 0 )
// movement = Vector3.right * forwardSpeed * moveTouchPad.position.x;
//else
// movement = Vector3.right * backwardSpeed * moveTouchPad.position.x;
// Apply movement from move joystick
if ( rightTouchPad.position.x > 0 )
movement += Vector3.right * forwardSpeed * rightTouchPad.position.x;
if ( leftTouchPad.position.x > 0 )
movement += Vector3.left * backwardSpeed * leftTouchPad.position.x;
Comment