I checked the code briefly before you removed most of it and I didn’t see you checking isGrounded when you were checking if a jump were possible aside from the logic involving cyoteTime.
public enum CharacterState
{
Grounded,
Jumping,
WallSliding,
Sliding
}
public class CharacterController : MonoBehaviour
{
public CharacterState currentState;
void Update()
{
// Update the character's behavior based on its current state
switch (currentState)
{
case CharacterState.Grounded:
// Handle grounded behavior
break;
case CharacterState.Jumping:
// Handle jumping behavior
break;
case CharacterState.WallSliding:
// Handle wall sliding behavior
break;
case CharacterState.Sliding:
// Handle sliding behavior
break;
default:
break;
}
}
// Method to transition to a new state
void TransitionToState(CharacterState newState)
{
currentState = newState;
}
// Example method to perform a jump
void Jump()
{
// Check if the character is grounded or wall sliding before allowing a jump
if (currentState == CharacterState.Grounded || currentState == CharacterState.WallSliding)
{
// Perform the jump action
TransitionToState(CharacterState.Jumping);
// Apply jump force, etc.
}
}
// Example method to perform wall slide
void WallSlide()
{
// Check if the character is touching a wall and not grounded
if (/* Condition to check if character is touching a wall */)
{
TransitionToState(CharacterState.WallSliding);
// Apply wall slide force, etc.
}
}
// Example method to perform slide
void Slide()
{
// Check if the character is grounded and moving with sufficient speed
if (/* Condition to check if character is grounded and moving with sufficient speed */)
{
TransitionToState(CharacterState.Sliding);
// Apply slide force, etc.
}
}
}
hey man didnt realize i had chopped off half the jumping script thank you for telling me if you could tell me where i would need to put that IsGrounded check that would be great
I’d personally take some time to learn about them for this case, it’s a perfect example and it’s used all the time for many different things when used properly.