Esempio n. 1
0
        /**
         * Pickup / Dropping
         */
        void Update()
        {
            // Drop the object we're holding if we're holding one
            if (Input.GetButtonDown("Grab") && heldObj && Time.time > pickupTime + 0.1f)
            {
                if (heldObj.tag == "Pickup")
                {
                    DropPickup();
                }
            }

            /*
             * if (animator && heldObj)
             * {
             *      animator.SetBool("HoldingPickup", (heldObj.tag == "Pickup"));
             *      animator.SetBool("HoldingPushable", (heldObj.tag == "Pushable"));
             * }
             */
            if (heldObj && heldObj.tag == "Pushable")
            {
                actorBody.RotateToDirection(heldObj.transform.position, rotateToObjectSpeed);
                if (Input.GetButtonUp("Grab"))
                {
                    DropPushable();
                }
            }

            // If we've exceeded pushBreakForce
            if (!joint && heldObj)
            {
                DropPushable();
            }
        }
Esempio n. 2
0
        /**
         * Apply player movement with physics calculations
         */
        void FixedUpdate()
        {
            grounded = CheckGroundSensors();

            ab.MoveTo(moveDirection, curAccel, 0.1f);

            if (curRotateSpeed != 0 && direction.magnitude != 0)
            {
                ab.RotateToDirection(moveDirection, curRotateSpeed);
            }

            ab.ManageSpeed(curDecel, maxSpeed);
        }