Beispiel #1
0
 //disables gravity and ignores collision with the player to prevent you from being shot into space
 public override void OnGrab()
 {
     print("grab");
     isGrabbed = true;
     GrabMgr.AddGrabbed(this.gameObject);
     this.GetComponent <BallRespawner>().SetHolding(true);
     Physics.IgnoreCollision(this.GetComponent <SphereCollider>(), player.GetComponent <CapsuleCollider>(), true);
     this.GetComponent <Attractable>().setAttractable(false);
     CheckActiveHand();
 }
Beispiel #2
0
    public override void OnRelease()
    {
        print("release");
        isGrabbed = false;
        GrabMgr.RemoveGrabbed(this.gameObject);
        this.transform.localScale = originalSize;               //maybe change this
        //this.transform.parent = player.gameObject.transform;

        this.GetComponent <Attractable>().setAttractable(true);
        Invoke("ResetCollider", 1f);    //prevents being stuck in player collider....most of the time
    }
Beispiel #3
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
    }
Beispiel #4
0
    public override void OnRelease()
    {
        print("release");
        isGrabbed = false;
        GrabMgr.RemoveGrabbed(this.gameObject);

        this.GetComponent <Attractable>().setAttractable(true);
        this.GetComponent <BallRespawner>().SetHolding(false);
        AddThrowForce();
        // player.transform.TransformVector(OVRInput.getlo)
        activeHand = -1;
        Invoke("ResetCollider", 1f);    //prevents being stuck in player collider on release....most of the time
    }
Beispiel #5
0
    public override void OnGrab()
    {
        if (snapZone.GetSnapped() == true && this.gameObject == snapZone.getSnappedObject())                  //makes sure to re-enable gravity and physics
        {
            snapZone.UnsnapObject();
        }

        print("grab");
        isGrabbed = true;
        //this.transform.parent = player.gameObject.transform;
        //this.transform.localScale = originalSize;  //puts back to normal size seed
        GrabMgr.AddGrabbed(this.gameObject);
        Physics.IgnoreCollision(this.GetComponent <BoxCollider>(), player.GetComponent <CapsuleCollider>(), true);
        this.GetComponent <Attractable>().setAttractable(false);
    }
Beispiel #6
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();
    }
Beispiel #7
0
 void CheckActiveHand()  //checks which hand is holding the ball
 {
     activeHand = GrabMgr.getLastGrabbed();
 }