Esempio n. 1
0
    void Update()
    {
        // Early exits
        if (!m_player || !m_player.enabled || m_player.IsControlled)
        {
            return;
        }

        // Check if player is in valid state
        if (m_player.GetState() != APCharacterController.State.Standard)
        {
            return;
        }

        // Check inputs and update animation according to this
        APAnimation anim   = m_targetFront;
        bool        bFront = Mathf.Abs(m_player.m_inputs.m_axisX.GetValue()) > 0f;
        bool        bUp    = m_player.m_inputs.m_axisY.GetValue() > 0f;
        bool        bDown  = m_player.m_inputs.m_axisY.GetValue() < 0f;

        if (bFront)
        {
            if (bUp)
            {
                anim = m_targetFrontUp;
            }
            else if (bDown)
            {
                anim = m_targetFrontDown;
            }
        }
        else if (bUp)
        {
            anim = m_targetUp;
        }
        else if (bDown)
        {
            anim = m_targetDown;
        }

        // Use front running animation if needed
        if ((anim == m_targetFront) && m_player.IsRunning() && (m_targetFrontRun.GetAnimHash() != 0))
        {
            anim = m_targetFrontRun;
        }

        m_player.PlayAnim(anim);
    }
Esempio n. 2
0
    void LateUpdate()
    {
        // update animation
        if (m_isControlling)
        {
            Settings oSettings = GetSettings();

            float fAbsY = Mathf.Abs(m_motor.m_velocity.y);

            // set speed
            float fSpeed             = oSettings.m_maxSpeed > Mathf.Epsilon ? fAbsY / oSettings.m_maxSpeed : 0f;
            m_player.GetAnim().speed = fSpeed;

            // set animation
            MoveDir     ePrevMoveDir = m_moveDir;
            APAnimation sAnim        = oSettings.m_animClimbUp;
            if (fSpeed < 1e-3f)
            {
                // special case when stopped, pause & keep previous animation
                m_player.GetAnim().speed = 0f;

                // first animation play is always up
                if (m_moveDir == MoveDir.undefined)
                {
                    m_moveDir = MoveDir.up;
                }
            }
            else if (m_motor.m_velocity.y > 0f)
            {
                sAnim     = oSettings.m_animClimbUp;
                m_moveDir = MoveDir.up;
            }
            else
            {
                sAnim     = oSettings.m_animClimbDown;
                m_moveDir = MoveDir.down;
            }

            if (ePrevMoveDir != m_moveDir)
            {
                m_player.PlayAnim(sAnim);
            }
        }
    }
Esempio n. 3
0
    void StartGrab(APCharacterController controlled, APAnimation anim, Vector2 grabHandle)
    {
        ClearRuntimeValues();

        m_controlled = controlled;
        m_controlled.IsControlled = true;

        // Init handle to grab
        m_curGrabHandle = transform.TransformPoint(grabHandle);
        MatchGrabAnchor();

        // start anim & reset velocity
        m_controlled.GetMotor().m_velocity = Vector2.zero;
        InitPhysAnimation(m_curGrabHandle);
        m_controlled.PlayAnim(anim);

        // launch events
        m_controlled.EventListeners.ForEach(e => e.OnEdgeGrabStart(this));
    }