I have my Ledge hanging state mostly completed, it working, I transition from the falling state to my ledge Hanging State, everything animates correct, but the Player does not “Grab” the ledge, it just goes into the hanging state, but continues to the ground while playing the hanging animation… I can see this because the Players collider goes back to the terrain.
My Player Hanging State
Thanks
public class PlayerHangingState : PlayerBaseState
{
private readonly int LedgeHangingBlendTreeHash = Animator.StringToHash("LedgeBlendTree");
protected readonly int LedgeMovementDirectionHash = Animator.StringToHash("LedgeMovementDirection");
private const float CrossFadeDuration = 0.1f;
private Vector3 closestPoint;
private Vector3 ledgeForward;
public PlayerHangingState(PlayerStateMachine stateMachine, Vector3 closestPoint, Vector3 ledgeForward) : base(stateMachine)
{
this.closestPoint = closestPoint;
this.ledgeForward = ledgeForward;
}
public override void Enter()
{
stateMachine.transform.rotation = Quaternion.LookRotation(ledgeForward, Vector3.up);
stateMachine.InputReader.LedgeClimbEvent += InputReader_LedgeClimbEvent;
stateMachine.InputReader.LedgeDropEvent += InputReader_LedgeDropEvent;
stateMachine.Animator.CrossFadeInFixedTime(LedgeHangingBlendTreeHash, CrossFadeDuration);
stateMachine.Animator.SetFloat(LedgeMovementDirectionHash, 0);
}
public override void Exit()
{
stateMachine.InputReader.LedgeClimbEvent -= InputReader_LedgeClimbEvent;
stateMachine.InputReader.LedgeDropEvent -= InputReader_LedgeDropEvent;
}
public override void Tick(float deltaTime)
{
Vector3 movement = new Vector3();
movement += stateMachine.transform.right * stateMachine.InputReader.MovementValue.x;
Move(movement, 1, deltaTime);
stateMachine.Animator.SetFloat(LedgeMovementDirectionHash, stateMachine.InputReader.MovementValue.x);
}
private void InputReader_LedgeDropEvent()
{
Debug.Log("Hanging - ledge drop event");
stateMachine.SwitchState(new PlayerFallState(stateMachine, 1));
}
private void InputReader_LedgeClimbEvent()
{
//Climb Ledge
Debug.Log("TO DO: Ledge Climbing!");
}
}