Example #1
0
    void Update()
    {
        if (!hasControl || isDead)
        {
            return;
        }

        float horizontal = GlobalControl.GetHorizontal(playerNum);
        float vertical   = GlobalControl.GetVertical(playerNum);

        rigid2d.velocity = new Vector2(horizontal, vertical).normalized *speed;

        float horizontalAim = GlobalControl.GetHorizontalAim(playerNum);
        float verticalAim   = GlobalControl.GetVerticalAim(playerNum);


        if (horizontalAim != 0f || verticalAim != 0f)
        {
            transform.up = new Vector3(horizontalAim + 0.01f, verticalAim, 0);
        }

        if (GlobalControl.GetButtonDownRT(playerNum))
        {
            ThrowBoomerang();
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        var x = (GlobalControl.GetHorizontal(playerNum) * 0.05f * mvSpeed);
        var y = (GlobalControl.GetVertical(playerNum) * 0.05f * mvSpeed);

        if (transform.position.x + x > bounds.max.x)
        {
            Debug.Log("Clamping " + transform.position.x + " into " + bounds.max.x);
            x = Mathf.Clamp(x, int.MinValue, 0);
        }
        else if (transform.position.x + x < bounds.min.x)
        {
            x = Mathf.Clamp(x, 0, int.MaxValue);
        }


        /*if (transform.position.y + y > bounds.max.y) {
         *      Debug.Log ("Clamping y!");
         *      y = Mathf.Clamp (y, 0, int.MaxValue);
         * }
         * else if(transform.position.y + y < bounds.min.x)
         *      y = Mathf.Clamp (y, int.MinValue,0);*/

        if (canMove)
        {
            transform.position += new Vector3(x, y, 0);
            Debug.Log("Moving by " + x + " " + y);
        }
    }
    // Update is called once per frame
    void Update()
    {
        float inputX = GlobalControl.GetHorizontal(num);
        float inputY = GlobalControl.GetVertical(num);
        float stepX  = inputX * Time.deltaTime * speed;
        float stepY  = inputY * Time.deltaTime * speed;

        if (transform.position.x > -6.25f && inputX < 0f || transform.position.x < 9 && inputX > 0f)
        {
            transform.position = new Vector3(transform.position.x + stepX, transform.position.y + stepY, transform.position.z);
        }
    }