// Update is called once per frame
 void Update()
 {
     if (collisionHands.TouchingFurniture() && GetComponent <CollisionHands>().isGrabbed&& Input.GetKey(KeyCode.Q))
     {
         Destroy(this.gameObject);
     }
 }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        controlWii = GetComponent <CollisionHands>().controlWii;
        if (collision.TouchingFurniture() && collision.isGrabbed && controlWii != null)
        {
            int ret;
            do
            {
                ret = controlWii.ReadWiimoteData();

                if (ret > 0 && controlWii.current_ext == ExtensionController.MOTIONPLUS)
                {
                    Vector3 offset = new Vector3(-controlWii.MotionPlus.PitchSpeed,
                                                 controlWii.MotionPlus.YawSpeed,
                                                 controlWii.MotionPlus.RollSpeed) / 95f;    // Divide by 95Hz (average updates per second from wiimote)
                                                                                            //wmpOffset += offset;

                    //model.rot.Rotate(offset, Space.Self);
                }
            } while (ret > 0);
            NunchuckData data = controlWii.Nunchuck;
            if (data.c && !data.z)
            {
                transform.parent = GameObject.FindGameObjectWithTag("vista").transform;
                Vector3 acc = GetAccelVector();
                transform.position   = new Vector3(transform.parent.position.x, transform.parent.position.y, transform.parent.position.z);
                transform.localScale = scale.actualScale / 3;
                if (acc.y >= -0.2f)
                {
                    transform.Rotate(new Vector3(0, 0, 10));
                }
                else if (acc.y <= -0.7f)
                {
                    transform.Rotate(new Vector3(0, 0, -10));
                }
                else if (data.stick[0] - 125 > 10)
                {
                    transform.Rotate(0, 10, 0);
                }
                else if (data.stick[0] - 125 < -10)
                {
                    transform.Rotate(0, -10, 0);
                }
                else if (data.stick[1] - 130 > 10)
                {
                    transform.Rotate(10, 0, 0);
                }
                else if (data.stick[1] - 130 < -10)
                {
                    transform.Rotate(-10, 0, 0);
                }
                else
                {
                    transform.localScale = scale.actualScale;
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        controlWii = GetComponent <CollisionHands>().controlWii;
        data       = DataWii();
        if (collisionHands.TouchingFurniture() && controlWii != null && data.z)
        {
            switch (transform.tag)
            {
            case "chair":
                ScaleX("chair");
                ScaleY("chair");
                ScaleZ("chair");
                break;

            case "sofa":
                ScaleX("sofa");
                ScaleY("sofa");
                ScaleZ("sofa");
                break;

            case "bookcase":
                ScaleX("bookcase");
                ScaleY("bookcase");
                ScaleZ("bookcase");
                break;

            case "vase":
                ScaleX("vase");
                ScaleY("vase");
                ScaleZ("vase");
                break;

            case "tv":
                ScaleX("tv");
                ScaleY("tv");
                ScaleZ("tv");
                break;

            case "bed":
                ScaleX("bed");
                ScaleY("bed");
                ScaleZ("bed");
                break;

            case "table":
                ScaleX("table");
                ScaleY("table");
                ScaleZ("table");
                break;
            }
        }
    }