Description
The UpdateDucking
method is part of the PlayerController
class in the Sandbox framework. This method is responsible for handling the player's ducking state during the game's fixed update cycle. It is called when the UseInputControls
property is enabled.
When invoked, the method checks the wantsDuck
parameter to determine if the player intends to duck. If wantsDuck
is true
, the player will enter a ducking state. If wantsDuck
is false
and the player is currently ducking, the method will attempt to unduck the player, provided there is sufficient headroom to do so safely.
Usage
To use the UpdateDucking
method, ensure that the UseInputControls
property of the PlayerController
is set to true
. Call this method during the fixed update cycle, passing a boolean value to indicate whether the player should duck or not.
Example usage:
PlayerController playerController = new PlayerController();
playerController.UseInputControls = true;
// Call this in FixedUpdate
playerController.UpdateDucking(true); // Player will duck
playerController.UpdateDucking(false); // Player will attempt to unduck if possible
Example
PlayerController playerController = new PlayerController();
playerController.UseInputControls = true;
// Call this in FixedUpdate
playerController.UpdateDucking(true); // Player will duck
playerController.UpdateDucking(false); // Player will attempt to unduck if possible