Weapon Drop Sounds

I am trying to accomplish drop sounds for weapons hitting the ground or flying from an explosion and hitting a wall.

My naive approach would be to just add some code to the weapon actors OnTick to detect when they’ve exceeded a certain ceiling speed and then when they’ve come back down under a floor speed assume they’ve stopped and play a sound.

I was thinking a better approach would be to detect collisions and try to gauge the magnitude of them and play a sound accordingly. Might anyone suggest where I could hook in to listen for hit events like this on an actor?

I use the ReceiveHit event on my pawn and call a method passing along the NormalImpulse vector parameter. The length of that vector basically tells you how hard the impact was. Something like this:



void AIkoPawn::ReceiveHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp,
			  bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit)
{
	Super::ReceiveHit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit);

	...

	PlayAudioImpact(NormalImpulse);

}




void AIkoPawn::PlayAudioImpact(FVector NormalImpulse)
{
	float ImpactStrength = FMath::GetMappedRangeValue(FVector2D(450000.f, 100000000.f), FVector2D(0.f, 1.f), NormalImpulse.Size());
	AudioImpactCue->SetVolumeMultiplier(FMath::Clamp(ImpactStrength, 0.f, 2.f));
	
	if (AudioImpactCue->VolumeMultiplier > 0.01f)
	{
		AudioImpactCue->Play();
	}
}


Ah thanks very much for that. I’ve overriden the ReceiveHit event on my weaponDrop actor yet I am not finding that drops to the floor are triggering ReceiveHit. Is there something I am missing?

edit: Ah nevermind I found out i had to set WeaponMesh->SetNotifyRigidBodyCollision(true);

Ah thanks very much for that. I’ve overriden the ReceiveHit event on my weaponDrop actor yet I am not finding that drops to the floor are triggering ReceiveHit. Is there something I am missing?

edit: Ah nevermind I found out i had to set WeaponMesh->SetNotifyRigidBodyCollision(true);
[/QUOTE]

Oh yeah, that is the equivalent of setting “Simulate Physics” on a Blueprint component. Without that it just won’t use any physics at all.