Player Rotation

The PlayerRotation is responsible for managing the rotation of the player character based on different states.

Properties

  • public PlayerWorker playerWorker: References the PlayerWorker associated with PlayerRotation.

  • public PlayerAttackRotation playerAttackRotation: References the rotation of the player when performing an attack.

  • public PlayerMovementRotation playerMovementRotation: References the rotation of the player during movement.

Constructor

  • public PlayerRotation(PlayerWorker playerWorker): Initializes a new instance of the PlayerRotation class, assigning the PlayerWorker. Also initializes instances of PlayerAttackRotation and PlayerMovementRotation to handle rotation during attacking and moving, respectively.

Methods

  • public void OnUpdate(): calls Rotate on each frame.

  • public void SetMovementTargetRotation(Vector3 rotation): Sets the target rotation for the player when moving. The target rotation is represented by a Vector3 and is converted to a Quaternion for the internal representation.

  • public void Rotate(): Determines how the player character should rotate based on the current state (moving or attacking). If the player is moving, it invokes the Rotate method of PlayerMovementRotation; if the player is attacking, it invokes the Rotate method of PlayerAttackRotation.

Last updated