void UpdateDucking( bool wantsDuck )

robot_2Generated
code_blocksInput

Description

The UpdateDucking method is part of the PlayerController class in the Sandbox framework. This method is responsible for managing the player's ducking state during the game's fixed update cycle. It is called when UseInputControls is enabled. The method will make the player duck if requested, and if the player is already ducked, it will attempt to unduck if there is sufficient room.

Usage

To use the UpdateDucking method, ensure that the PlayerController instance has UseInputControls enabled. Call this method within the fixed update loop, passing a boolean parameter to indicate whether the player wants to duck.

Parameters:

  • wantsDuck (Boolean): A boolean value indicating whether the player wants to duck. Pass true to initiate ducking, or false to attempt to unduck if possible.

Example

// Example usage of UpdateDucking method
public class MyPlayerController : PlayerController
{
    public override void FixedUpdate()
    {
        base.FixedUpdate();

        // Assume we have a method to check if the duck button is pressed
        bool isDuckButtonPressed = CheckDuckButton();

        // Update the ducking state based on the button press
        UpdateDucking(isDuckButtonPressed);
    }

    private bool CheckDuckButton()
    {
        // Implement your input logic here
        return Input.Pressed(InputButton.Duck);
    }
}