2023-08-27 02:58:19 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using BITFALL.Player.Movement;
|
|
|
|
using BITKit.StateMachine;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace BITFALL.Entities.Player.Movement.States
|
|
|
|
{
|
|
|
|
[Serializable]
|
|
|
|
public class Climb : PlayerCharacterState,IPlayerClimbState
|
|
|
|
{
|
|
|
|
|
|
|
|
[SerializeField] protected float lerpDelta = 5;
|
|
|
|
public override void OnStateEntry(IState old)
|
|
|
|
{
|
|
|
|
actor.alwaysNotGrounded = true;
|
|
|
|
actor.ForceNotGrounded();
|
|
|
|
actor.ColliderComponent.enabled = false;
|
|
|
|
}
|
|
|
|
public override void OnStateUpdate(float deltaTime)
|
|
|
|
{
|
2023-10-02 23:24:56 +08:00
|
|
|
if (Vector3.Distance(characterController.ExpectClimb.shouldBe, characterController.transform.position) < 0.1f || actor.IsStable)
|
2023-08-27 02:58:19 +08:00
|
|
|
{
|
|
|
|
characterController.TransitionState<Walk>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public override void OnStateExit(IState old, IState newState)
|
|
|
|
{
|
|
|
|
actor.alwaysNotGrounded = false;
|
|
|
|
actor.ColliderComponent.enabled = true;
|
|
|
|
characterController.ExpectJump.Reset();
|
|
|
|
actor.ForceGrounded();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
|
|
|
|
{
|
2023-10-02 23:24:56 +08:00
|
|
|
currentVelocity =(characterController.ExpectClimb.shouldBe - characterController.transform.position)*lerpDelta;
|
2023-08-27 02:58:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|