Exemplo n.º 1
0
 private void Update()
 {
     if (bAnimIsWallRiding)
     {
         float xInput = CharacterMovement.GetMovementInput().x;
         if (xInput * CachedWallDirection <= EHCharacterMovementComponent.JOYSTICK_WALK_THRESHOLD)
         {
             if (CharacterAnim.GetBool(ANIM_WALL_HOLD))
             {
                 CharacterAnim.SetBool(ANIM_WALL_HOLD, false);
                 return;
             }
         }
         if (Physics2D.Velocity.y < -MaxFallSpeed)
         {
             Physics2D.Velocity = new Vector2(Physics2D.Velocity.x, -MaxFallSpeed);
         }
     }
     else if (ColliderWeAreOn)
     {
         if (CachedWallDirection * CharacterMovement.GetMovementInput().x > EHCharacterMovementComponent.JOYSTICK_WALK_THRESHOLD)
         {
             if (!CharacterAnim.GetBool(ANIM_WALL_HOLD))
             {
                 CharacterAnim.SetBool(ANIM_WALL_HOLD, true);
             }
         }
     }
 }
Exemplo n.º 2
0
    /// <summary>
    /// Coroutine that performs our character's dash based on the direction of their input and the dash
    /// animation curve
    /// </summary>
    /// <returns></returns>
    private IEnumerator PerformDash()
    {
        Vector2 MovementInputAxis = MovementComponent.GetMovementInput();

        Vector2 DashDirection;

        if (MovementInputAxis.x == 0)
        {
            MovementInputAxis = Vector2.right * (MovementComponent.GetIsFacingLeft() ? -1 : 1);
        }

        float HorizontalDashDirection = MovementInputAxis.x != 0 ? Mathf.Sign(MovementInputAxis.x) : 0;
        float VerticalDashDirection   = 0;//Mathf.Abs(MovementInputAxis.y) > EHCharacterMovementComponent.JOYSTICK_WALK_THRESHOLD ? Mathf.Sign(MovementInputAxis.y) : 0;

        DashDirection = new Vector2(HorizontalDashDirection, VerticalDashDirection);
        DashDirection.Normalize();

        MovementComponent.SetIsFacingLeft(DashDirection.x, true);
        float TimeThatHasPassed = 0;
        float CachedGravity     = Physics2D.GravityScale;

        Physics2D.GravityScale = 0;
        while (TimeThatHasPassed < DashTime && bIsPerformingDash)
        {
            Physics2D.Velocity = DashAnimationCurve.Evaluate(TimeThatHasPassed / DashTime) * DashDirection * DashSpeed;
            yield return(null);

            TimeThatHasPassed += EHTime.DeltaTime;
        }
        Physics2D.GravityScale = CachedGravity;
    }