예제 #1
0
    // Update is called once per frame
    void Update()
    {
        float   joystickX   = controls.getRightStickX();
        float   joystickY   = controls.getRightStickY();
        Vector3 joystickVec = new Vector3(joystickX, joystickY, 0);

        if (controls.getRightTriggerDown())
        {
            if (joystickVec != Vector3.zero)
            {
                GameObject pellet = Instantiate(pelletObj, transform.position, Quaternion.identity);
                pellet.GetComponent <Pellet>().SetOwner(transform.parent.GetComponent <PlayerController>().GetPlayerNumber());
                pellet.GetComponent <Rigidbody2D>().AddForce(joystickVec * pelletSpeed);
            }
            //SHOOT
        }
        cursorPos = joystickVec;
        cursorPos.Normalize();
        cursorPos = cursorPos * radius;
        if (joystickVec != Vector3.zero)
        {
            transform.localPosition = cursorPos;
            transform.up            = joystickVec;
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        float   joystickX = controls.getRightStickX();
        float   joystickY = controls.getRightStickY();
        Vector3 offset    = new Vector3(joystickX, joystickY, 0);

        transform.position = transform.position + offset * speed;
        // rb.AddForce(offset * speed);
    }