Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  

touch x & y position on screen [cs]


hey guys, so i managed to code touch analog stick for android ant pc, its track mouse x and y position and draw small dot under you finger + biger dot as housing of analog whenewer u touch on  the screen, then disapear when u release the screen, and its actualy works, i can control my topdown shooter character in both x y axis as its supposed to be. But my problem is that i need 2 of analog sticks, but mouse is only one and its detect as one imput,  just like not multitouch sreen. :(


so is there such thing like imput.touchPosition so i could use array of touches and it would fit to my script without much editing ? i tried to google but no luck.

Please login or register to see this code.

the script tracks x and y of mouse, then in playerscript i get those values, and from TOUCH X START POSITION  (i declaring it when touch started) take (minus) curent mouse position, therefore output is valueX. 




if (isDraging){

              valueX = analogPosition.x - secondPosition.x;  /// -2, -1, 0, 1, 2

              rb.addforce. right = valueX;




//// link to image                Please login or register to see this link.

Share this post

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this