Example #1
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);

                    // Use smooth loco method if available
                    if (smoothLocomotion)
                    {
                        smoothLocomotion.MoveCharacter(moveDirection * Time.deltaTime * triggerValue);
                    }
                    // Fall back to character controller
                    else if (characterController)
                    {
                        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;
                    playerClimbing.AddClimber(ClimbHelper, thisGrabber);
                    climbing = true;
                }
            }
        }
Example #2
0
        public override void GrabItem(Grabber grabbedBy)
        {
            // Add the climber so we can track it's position for Character movement
            if (playerClimbing)
            {
                playerClimbing.AddClimber(this, grabbedBy);
            }

            base.GrabItem(grabbedBy);
        }