1
\$\begingroup\$

I am stuck with an issue of moving the slider on android mobiles with finger touch event while developing pong game in unity 3D, though its working fine for pc.

This game is developed in 2D environment... please help me if anyone have available solution to this issue enter image description here

Actually I have developed this game for pc so I have code for the movement of slider accordingly as below:

var keyup:KeyCode;
var keydown:KeyCode;
var speed:float=1;

function Update () {
    if(Input.GetKey(keyup))
        rigidbody2D.velocity.y=speed;
    else if(Input.GetKey(keydown))
        rigidbody2D.velocity.y=speed*-1;
    else
        rigidbody2D.velocity.y=0;
}

But now i want to use this game for android mobiles.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

You can create a script attached to the object you want to drag and adapt your code to work inside OnMouseDown() & OnMouseDrag()

\$\endgroup\$
2
  • \$\begingroup\$ Do OnMouseDown() & OnMouseDrag() will work for android mobile devices ?? \$\endgroup\$ Commented Jul 10, 2015 at 7:11
  • \$\begingroup\$ Yes they will work fine. Input.GetKeyDown(KeyCode.Mouse0) will also work for a single tap/touch event \$\endgroup\$ Commented Jul 10, 2015 at 12:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .