APawn::PawnStartFire
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtual
Description
Called by the PlayerController when the player presses a fire input. The base implementation is empty — override this in your pawn subclass to implement weapon firing or any action triggered by the fire button.
Caveats & Gotchas
- • This is a legacy entry point from the old input system and is only called when using the deprecated PlayerController::StartFire() binding. Projects using Enhanced Input should bind fire actions directly in SetupPlayerInputComponent() and not rely on this function.
- • The FireModeNum parameter is passed through from PlayerController::StartFire(uint8) — if you bind fire using the old input axis/action system, FireModeNum is always 0 unless you call StartFire(1) explicitly.
Signature
virtual void PawnStartFire(uint8 FireModeNum = 0) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| FireModeNum | uint8 | Index identifying which fire mode to activate (0 = primary, 1 = secondary, etc.). | 0 |
Return Type
void Example
Route fire modes to a weapon component C++
void AMyPawn::PawnStartFire(uint8 FireModeNum)
{
if (WeaponComponent)
{
if (FireModeNum == 0)
{
WeaponComponent->StartPrimaryFire();
}
else if (FireModeNum == 1)
{
WeaponComponent->StartSecondaryFire();
}
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?