APawn::GetPawnNoiseEmitterComponent
#include "GameFramework/Pawn.h"
Access: public
Specifiers: virtualconst
Description
Returns the PawnNoiseEmitterComponent for this pawn, if one exists. The default implementation searches the components array, and if not found, falls back to checking the pawn's current Controller.
Caveats & Gotchas
- • The linear search through all components can be slow if the pawn has many components. Override this in your subclass and cache the result to avoid repeated searches.
- • Returns nullptr if neither the pawn nor its controller owns a UPawnNoiseEmitterComponent, which is the common case unless you explicitly added one.
Signature
virtual UPawnNoiseEmitterComponent* GetPawnNoiseEmitterComponent() const; Return Type
UPawnNoiseEmitterComponent* Example
Trigger noise from a custom pawn C++
void AMyPawn::MakeFootstepNoise()
{
if (UPawnNoiseEmitterComponent* NoiseEmitter = GetPawnNoiseEmitterComponent())
{
NoiseEmitter->MakeNoise(this, 0.5f, GetActorLocation());
}
} See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?