Exemplo n.º 1
0
    // This function is called every fixed framerate frame, if the MonoBehaviour is enabled
    void FixedUpdate()
    {
        //float moveHorizontal = Input.GetAxis ("Horizontal");

        Vector2 touchPoint = touchPad.GetTouchedPoint();

        if (touchPoint != Vector2.zero)
        {
            //Debug.Log ("Touched screen at point: " + touchPoint);
            //Debug.Log ("Screen width: " + Screen.width);
            Vector3 movement;
            if (touchPoint.x < Screen.width / 2)
            {
                movement = new Vector3(-1, 0.0f, 0.0f);                   //There should not be be any action upwards or downwards so Y axis motion is set to zero and the player can only control moving to the left or right. So the Z axis is set to zero
            }
            else
            {
                movement = new Vector3(1, 0.0f, 0.0f);         //There should not be be any action upwards or downwards so Y axis motion is set to zero and the player can only control moving to the left or right. So the Z axis is set to zero
            }
            rb.AddForce(movement * controlSpeed);              //implement motion with a certain speed
        }

        //Vector3 movement = new Vector3 (moveHorizontal, 0.0f,0.0f);     //There should not be be any action upwards or downwards so Y axis motion is set to zero and the player can only control moving to the left or right. So the Z axis is set to zero
        //rb.AddForce (movement * controlSpeed); //implement motion with a certain speed
    }