Esempio n. 1
0
        public override void GrabItem(Grabber grabbedBy)
        {
            // Add the climber so we can track it's position for Character movement
            if (bngController == null)
            {
                bngController = GameObject.FindGameObjectWithTag("Player").GetComponent <BNGPlayerController>();
            }
            bngController.AddClimber(this, grabbedBy);

            base.GrabItem(grabbedBy);
        }
Esempio n. 2
0
        void reelInGrapple(float triggerValue)
        {
            // Has the collider been destroyed or disabled?
            if (validTargetFound && grappleTargetCollider != null && !grappleTargetCollider.enabled)
            {
                dropGrapple();
                return;
            }

            if (validTargetFound && currentGrappleDistance > MinReelDistance)
            {
                // Move object towards our hand
                if (isDynamic)
                {
                    grappleTargetRigid.isKinematic      = false;
                    grappleTargetRigid.transform.parent = grappleTargetParent;
                    grappleTargetRigid.useGravity       = false;
                    grappleTargetRigid.AddForce((MuzzleTransform.position - grappleTargetRigid.transform.position) * 0.1f, ForceMode.VelocityChange);

                    //r.MovePosition(MuzzleTransform.position * Time.deltaTime);
                }
                // Move character towards Hit location
                else
                {
                    Vector3 moveDirection = (HitTargetPrefab.position - MuzzleTransform.position) * GrappleReelForce;

                    // Turn off gravity before we move
                    changeGravity(false);
                    characterController.Move(moveDirection * Time.deltaTime * triggerValue);
                }
            }
            else if (validTargetFound && currentGrappleDistance <= MinReelDistance)
            {
                if (isDynamic)
                {
                    //grappleTargetRigid.useGravity = true;
                    grappleTargetRigid.velocity         = Vector3.zero;
                    grappleTargetRigid.isKinematic      = true;
                    grappleTargetRigid.transform.parent = transform;
                }

                if (!climbing && !isDynamic)
                {
                    // Add climbable / grabber
                    ClimbHelper.transform.localPosition = Vector3.zero;
                    bngController.AddClimber(ClimbHelper, thisGrabber);
                    climbing = true;
                }
            }
        }