Я хочу реализовать долгое касание экрана. Если пользователь долго нажимает на экран, положение осей x и y уменьшается, и как только он отпускает касание, x увеличивается, а y уменьшается. я кое с чем возился, но не повезло .. вот код, который я пытался.
public class move : MonoBehaviour
{
public Vector2 velocity = new Vector2(40,40);
public float forwardspeed=0.02f;
Vector2 movement;
// Use this for initialization
void Start ()
{
Debug.Log("start+"+Input.touchCount);
movement.x+=(forwardspeed);
movement.y-=(forwardspeed);
rigidbody2D.velocity = movement;
}
// Update is called once per frame
void FixedUpdate ()
{
int i=0;
while (i < Input.touchCount)
{
// Is this the beginning phase of the touch?
if (Input.GetTouch(i).phase == TouchPhase.Began)
{
Debug.Log("input touch count"+Input.touchCount);
// rigidbody2D.gravityScale =0;
movement.x+=(forwardspeed);
movement.y+=(forwardspeed);
rigidbody2D.velocity = movement;
}
else if (Input.GetTouch(i).phase == TouchPhase.Ended)
{
movement.x += (forwardspeed);
movement.y -= (forwardspeed);
rigidbody2D.velocity = movement;
}
++i;
}
}
}
Moved || Stationary
- person Imapler   schedule 17.09.2014