The Player
reads the input and passes it to the CharacterController.
CharacterController
implements the ICharacterController
interface. When these methods are called, depending on the current state, the features are called in the correct and explicit order.
-
ICharacterController
is an interfrace from the low-level Kinematic Character Controller package. Its engine calls the implemented methods (UpdateRotation
,BeforeCharacterUpdate
, etc) when needed. -
Feature is an encapsulated logic of
CharacterController
:MovementFeature
,JumpingFeature
etc.
public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
{
switch (CurrentState)
{
case CharacterState.Default:
_movementFeature.UpdateVelocity(ref currentVelocity, deltaTime);
_jumpingFeature.UpdateVelocity(ref currentVelocity, deltaTime);
_gravityFeature.UpdateVelocity(ref currentVelocity, deltaTime);
_dragFeature.UpdateVelocity(ref currentVelocity, deltaTime);
_externalForceFeature.UpdateVelocity(ref currentVelocity, deltaTime);
break;
case CharacterState.Charging:
_chargingFeature.UpdateVelocity(ref currentVelocity, deltaTime);
break;
case CharacterState.NoClip:
_noClipFeature.UpdateVelocity(ref currentVelocity, deltaTime);
break;
default:
break;
}
}