Game Development Reference
In-Depth Information
PlayerStateController.onStateChange +=
onPlayerStateChange;
}
void OnDisable()
{
PlayerStateController.onStateChange -=
onPlayerStateChange;
}
void onPlayerStateChange(PlayerStateController.playerStatesnewState
)
{
currentPlayerState = newState;
}
void LateUpdate()
{
// Update based on our current state
onStateCycle();
// Continue moving to the current target position
currLerpDistance += cameraTrackingSpeed;
transform.position = Vector3.Lerp(lastTargetPosition,
currTargetPosition, currLerpDistance);
}
// Every cycle of the engine, process the current state
void onStateCycle()
{
/*We use the player state to determine the current action that the
camera should take. Notice that in most cases we are tracking the
player - however, in the case of killing or resurrecting, we don't
want to track the player.*/
switch(currentPlayerState)
{
case PlayerStateController.playerStates.idle:
trackPlayer();
break;
case PlayerStateController.playerStates.left:
trackPlayer();
 
Search WWH ::




Custom Search