UnityPlatformer.Ladder.IsAtBottom C# (CSharp) Method

IsAtBottom() public method

Return if the Character is very close to the bottom
public IsAtBottom ( Character c, Vector2 pos ) : bool
c Character
pos UnityEngine.Vector2
return bool
    virtual public bool IsAtBottom(Character c, Vector2 pos) {
      float bottomY = GetBottom().y;

      return Mathf.Abs(pos.y - bottomY) < c.pc2d.skinWidth;
    }
    /// <summary>

Usage Example

        public override void PerformAction(float delta)
        {
            // guard: something goes wrong!
            if (character.ladder == null)
            {
                character.ExitState(States.Fence);
                return;
            }
            Ladder ladder = character.ladder;

            Vector2 in2d = input.GetAxisRaw();

            if (character.IsOnArea(Areas.Fence) && character.IsOnState(States.Fence))
            {
                // disable x movement
                character.velocity.x = 0;
                character.velocity.y = speed * in2d.y;
            }

            if (ladder.topDismount && ladder.IsAtTop(character, character.feet) && in2d.y > 0)
            {
                // top dismount enabled and reached
                character.velocity = Vector2.zero;
                ladder.Dismount(character);
            }
            else if (ladder.bottomDismount && ladder.IsAtBottom(character, character.feet) && in2d.y < 0)
            {
                // bottom dismount enabled and reached
                character.velocity = Vector2.zero;
                ladder.Dismount(character);
            }
            else if (!ladder.topDismount && ladder.IsAboveTop(character, character.head) && in2d.y > 0)
            {
                // can't dismount (vine) don't let the head 'overflow' the ladder
                character.velocity = Vector2.zero;
            }
            else if (!ladder.bottomDismount && ladder.IsAtBottom(character, character.feet) && in2d.y < 0)
            {
                // can't dismount (vine) don't let the head 'overflow' the ladder
                // caveat: Vine cannot be near ground
                character.velocity = Vector2.zero;
            }

            character.SetFacing(in2d.x);

            // check for dismount conditions
            if (in2d.x != 0)
            {
                // do not allow to jump without telling the direction.
                // move up if you want it
                if (dismountJumping && input.IsActionHeld(actionJump.action))
                {
                    dismount.Reset();
                    character.ladder.Dismount(character);
                    character.ladder = null;

                    actionJump.Jump(new JumpConstant(character,
                                                     jumpOff.Clone((int)character.faceDir)
                                                     ));
                }
                else if (dismount.IncReady())
                {
                    character.velocity = Vector2.zero;
                    character.ladder.Dismount(character);
                    character.ladder = null;
                }
            }
            else
            {
                dismount.Reset();
            }
        }
All Usage Examples Of UnityPlatformer.Ladder::IsAtBottom