Example #1
0
    //Character needs to be touching a Zipline object
    public override bool IsApplicable()
    {
        if (!m_IsActive && ((Time.time - m_LastZiplineClimbTime < m_ZiplineClimbCoolDown) || m_ControlledCollider.GetVelocity().y > 0.0f))
        {
            return(false);
        }
        if (m_CanReleaseZiplineWithInput)
        {
            if ((DoesInputExist("ClimbRelease") && GetButtonInput("ClimbRelease").m_IsPressed) ||
                GetDirInput("Move").m_Direction == DirectionInput.Direction.Down)
            {
                return(false);
            }
        }
        if (m_ControlledCollider.IsGrounded())
        {
            return(false);
        }
        Zipline zipline = null;

        if (m_IsActive)
        {
            zipline = m_CurrentZipline;
        }
        else
        {
            zipline = FindZipline();
        }
        if (zipline)
        {
            if (!m_IsActive)
            {
                m_IsSkating = zipline.IsSkateLine();
                Vector3 newPoint = zipline.GetClosestPointOnZipline(GetAttachPoint());

                Vector3 diff = newPoint - GetAttachPoint();
                if (m_ControlledCollider.GetCapsuleTransform().CanMove(diff))
                {
                    return(true);
                }
            }
            else
            {
                //We might have been blocked from attaching too closely to the zipline. Let's make sure that we can actually attach
                if (zipline.GetDistToClosestPointOnZipline(GetAttachPoint()) > m_ZiplineReachRadius)
                {
                    return(false);
                }
                Vector3 travelSpeed = zipline.GetTravelVelocity(GetAttachPoint(), m_ControlledCollider.GetVelocity());
                if (zipline.GetDistToEnd(GetAttachPoint(), travelSpeed) < zipline.GetLetGoDistance())
                {
                    return(false);
                }
                return(true);
            }
        }
        return(false);
    }
Example #2
0
    //Called whenever this module is started (was inactive, now is active)
    protected override void StartModuleImpl()
    {
        Zipline zipline = FindZipline();

        if (zipline)
        {
            //Find our zipline, attach ourselves to it from the bottom or top depending on whether or not it is marked as a "skateline"
            m_CurrentZipline = zipline;
            m_IsSkating      = zipline.IsSkateLine();
            Vector3 newPoint = zipline.GetClosestPointOnZipline(GetAttachPoint());
            SetAttachPoint(newPoint);
        }
    }
Example #3
0
    //Move along Zipline
    //Called for every fixedupdate that this module is active
    public override void FixedUpdateModule()
    {
        if (m_CanJumpFromZipline)
        {
            if (TryZiplineJump())
            {
                EndModule();
                return;
            }
        }

        if (m_CurrentZipline == null)
        {
            return;
        }

        Vector3 travelSpeed = m_CurrentZipline.GetTravelVelocity(GetAttachPoint(), m_ControlledCollider.GetVelocity());
        Vector3 dir         = m_CurrentZipline.GetTravelDirection(GetAttachPoint(), travelSpeed);
        Vector3 acceleration;

        if (travelSpeed.magnitude < m_MaxSpeed)
        {
            acceleration = dir * m_DownhillAcceleration * Time.fixedDeltaTime;
            if (dir.y > 0.0f)              //We're going uphill, so use our uphillacceleration (usually negative so that we start sliding down)
            {
                acceleration = dir * m_UphillAcceleration * Time.fixedDeltaTime;
            }
        }
        else        //We're going too fast, so let's slow down
        {
            acceleration = -dir * m_Deceleration * Time.fixedDeltaTime;
        }
        travelSpeed += acceleration;
        if (!m_ControlledCollider.GetCapsuleTransform().CanMove(travelSpeed * Time.fixedDeltaTime))
        {
            //We're probably being blocked by something, reset our forward velocity
            travelSpeed *= 0.0f;
        }

        m_ControlledCollider.UpdateWithVelocity(travelSpeed);

        //Clamp to the Zipline after we've moved
        Vector3 position    = GetAttachPoint();
        Vector3 newPosition = m_CurrentZipline.GetClosestPointOnZipline(position);

        SetAttachPoint(newPosition);
        m_ControlledCollider.UpdateContextInfo();
    }