Announcement

Collapse
No announcement yet.

Weapon Drop Sounds

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?

    #2
    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:
    Code:
    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);
    
    }
    Code:
    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();
    	}
    }

    Comment


      #3
      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);
      Last edited by Mentos; 11-12-2014, 03:46 PM.

      Comment


        #4
        Originally posted by Mentos View Post
        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);
        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.

        Comment

        Working...
        X