示例#1
0
    public void PullInput(InputType type)
    {
        switch (type)
        {
        case InputType.Down:
            pull.StartPull();

            if (pull.HasTarget)
            {
                lineRenderer.ActivateLine();
                lineRenderer.UpdateLine(transform.position, jointController.GetGrapplePoint());
            }

            break;

        case InputType.Hold:
            pull.UpdatePull();

            if (pull.HasTarget)
            {
                lineRenderer.UpdateLine(transform.position, jointController.GetGrapplePoint());
            }
            else
            {
                lineRenderer.DeactivateLine();
            }

            break;

        case InputType.Release:
            pull.EndPull();
            lineRenderer.DeactivateLine();
            break;
        }
    }
示例#2
0
    public void UpdatePush()
    {
        if (HasTarget)
        {
            //Are we still in range of the point we are pushing away from?
            if (Vector2.Distance(transform.position, jointController.GetGrapplePoint()) < pushDistance)
            {
                //Get the direction of the player from the grapple point
                Vector3 direction = transform.position - jointController.GetGrapplePoint();

                //Apply force to the object in the direction
                forceToApply = true;
                forceAmount  = direction * pushForce * Time.deltaTime;

                jointController.UpdateJoint(pushForce * Time.deltaTime);
            }
            else
            {
                player.DeactivateLineRenderer();
                EndPush();
            }
        }
    }