Exemplo n.º 1
0
    void FixedUpdate()      //all turning mechanics are here
    {
        if (Mathf.Abs(inputAxis.x) < deadZone)
        {
            inputAxis.x = 0;
        }

        Quaternion        currentRot     = this.transform.rotation;
        List <GameObject> grabbedObjects = GrabMgr.getGrabbed();

        Quaternion newRot = new Quaternion();

        if (isTrigger && inputAxis.x != 0)
        {
            //allows for correct rotation in regards to orientation on planet
            if (snapReady)
            {
                if (inputAxis.x > 0)
                {
                    //newRot = currentRot * Quaternion.Euler(1, snapAmt, 1);
                    transform.Rotate(0, 45, 0);

                    foreach (GameObject go in grabbedObjects)
                    {
                        go.transform.Rotate(0, 45, 0);
                    }
                }
                else
                {
                    transform.Rotate(0, -45, 0);
                    foreach (GameObject go in grabbedObjects)
                    {
                        go.transform.Rotate(0, -45, 0);
                    }
                    //newRot = currentRot * Quaternion.Euler(1, -snapAmt, 1);
                }


                snapReady = false;
                StartCoroutine(SnapCoolDown());
            }

            prevPos = this.transform.position;
        }
        else
        {
        }



        //upate rotation
    }
Exemplo n.º 2
0
    public void SnapObject()
    {
        print("Snap");
        isSnapped = true;
        //playSound here
        if (gos != null)
        {
            GameObject[] objs = gos;
            foreach (GameObject go in objs)
            {
                if (GrabMgr.getGrabbed().Contains(go))
                {
                    GrabMgr.RemoveGrabbed(go);
                }

                //go.GetComponent<BGrab>().SetTestTrigger(true);
                //go.GetComponent<BridgePieceGrab>().OnRelease();
                go.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY
                                                            | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY
                                                            | RigidbodyConstraints.FreezePositionZ;

                go.GetComponent <Attractable>().setAttractable(false);
                // go.GetComponent<BridgePieceGrab>().ResetSize();

                go.GetComponent <Renderer>().material.color = go.GetComponent <MagicBoxGrab>().GetColor();

                go.GetComponent <MagicBoxGrab>().GrowObject();
                // this.GetComponentInChildren<AttachOrientationCorrection>().AdjustOrientation();
                go.layer = 10; ///makes object ground for gravity calculations
            }
        }
        if (curObject[0] != null)
        {
            for (int i = 0; i < curObject.Length; i++)
            {
                //curObject[i].GetComponent<Rigidbody>().isKinematic = true;

                Physics.IgnoreCollision(boxBase, curObject[i].GetComponent <BoxCollider>(), true);
                //Physics.IgnoreCollision(curObject[i].GetComponent<BoxCollider>(), this.GetComponentInChildren<BoxCollider>(), true);
            }

            snappedObject = curObject;
        }

        // this.GetComponentInChildren<BoxCollider>().enabled = true; //sets fake trigger so chair can stand on legs

        // AssemblyProgressCounter.S.IncrementSnap();
    }