Sound played twice when changing camera mode

I have found the next bug - sound played twice when changing camera mode. It was in 4.6 and in 4.7 and now is in 4.8.1
I think it can be reproduced with shooter example.
What i do:
I change camera style to firstperson, then i make fire from weapon with firesound played for first person, i hear it like i shoot, then i press button to change camera style to third person, and it goes behind a pawn to some distance to pawn, at this moment weapon hide, and i hear same fire sound like someone shoot in front of me. There is no more sound play calls in code, and also if i make a fire, then wait a while till sound playing be finished and after then i change view to 3rd person - then i hear no firesound be played again.
Look like if i play sound and change view mode until sound playing is finished, then i hear the same sound for other view mode.

Hi ,

I was trying to reproduce this issue in the shooter game but have not been able to so far. Please describe the steps you are taking to change camera styles between the first person camera and third person camera.


Tnx for reply.

By button press i call:

void AMyPlayerController::ToggleFirstPersonView()
	bShowMouseCursor = false;
	bEnableMouseOverEvents = false;

void AMyPlayerController::ToggleThirdPersonView()

	bShowMouseCursor = true;
	bEnableMouseOverEvents = true;

My camera class have only 2 functions:

void AMyPlayerCamera::SetCameraMode(ECameraMode aMode)
	CameraMode = aMode;

	switch (aMode)
	case ECameraMode::FirstPerson:
		CameraStyle == FName(TEXT("FirstPerson"));
		TargetDistance = FirstPersonDistance;
	case ECameraMode::ThirdPerson:
		CameraStyle == FName(TEXT("ThirdPerson"));
		TargetDistance = MinCameraDistance;
	case ECameraMode::DeveloperMode:
		CameraStyle == FName(TEXT("FirstPerson"));
		TargetDistance = 0.f;

This function is called by playercontroller, and it changes CameraStyle and distance from camera to possessed pawn.

Then is normal camera update is going:

void AMyPlayerCamera::UpdateViewTarget(FTViewTarget& OutVT, float DeltaTime)
	APlayerCameraManager::UpdateViewTarget(OutVT, DeltaTime);
	FRotator lPCRot = GetOwningPlayerController()->GetControlRotation();

	FRotator lCamRot = OutVT.POV.Rotation;

	FRotator lCurrentRot(0, lCamRot.Yaw, 0);
	FRotator lTargetRot(0, lPCRot.Yaw, 0);
	FRotator lNewRot = FMath::RInterpTo(lCurrentRot, lTargetRot, DeltaTime, TurnSpeed);

	float CurrentPitchAngle = FMath::FInterpTo(lCamRot.Pitch, lPCRot.Pitch, DeltaTime, PitchSpeed);
	lNewRot.Pitch = FMath::ClampAngle(CurrentPitchAngle, ViewPitchMin, ViewPitchMax);

	FreeCamDistance = FMath::FInterpTo(FreeCamDistance, TargetDistance, DeltaTime, ZoomSpeed);

float lSideDistanceAlpha = ((FreeCamDistance - MinCameraDistance) / (MaxCameraDistance - MinCameraDistance));
	FVector lOffset = FreeCamOffset;
	lOffset.Y = FMath::Lerp(FreeCamOffset.Y, 0.f, lSideDistanceAlpha);

	FVector lCenter = OutVT.Target->GetActorLocation();

	FVector lNewLoc = lCenter + FRotationMatrix(lNewRot).TransformVector(lOffset) - lNewRot.Vector() * FreeCamDistance;

	FCollisionQueryParams BoxParams(FName(TEXT("ThirdPerson")), false, this);
	FHitResult Result;

	FVector lTestCenter = lCenter + lOffset;

	GetWorld()->SweepSingleByChannel(Result, lTestCenter, lNewLoc, FQuat::Identity, ECC_Camera, FCollisionShape::MakeBox(FVector(12.f)), BoxParams);

	if (Result.bBlockingHit)
		lNewLoc = FMath::VInterpTo(GetCameraLocation(), Result.Location, DeltaTime, ZoomSpeed);
	OutVT.POV.Location = lNewLoc;
	OutVT.POV.Rotation = lNewRot;

Hey -

I’m trying to follow your code to reproduce this. What data type does LocalCamera belong to? Is the AMyPlayerCamera class based on PlayerCameraManager? If possible could you post the full header and source files for the classes used in your test?


I do not want to post full sources on public, but i can send it to your mail or paste here only pieces.
#pragma once
#include “MyPlayerCamera.generated.h”

class AMyPlayerCamera : public APlayerCameraManager

	AMyPlayerCamera(const FObjectInitializer& ObjectInitializer);

	virtual void UpdateViewTarget(FTViewTarget& OutVT, float DeltaTime) override;

	virtual void SetCameraMode(ECameraMode aMode);

	UPROPERTY(EditDefaultsOnly, Category = "PlayerCameraManager")
	float TargetingFOV;

	UPROPERTY(EditDefaultsOnly, Category = "PlayerCameraManager")
	float NormalFOV;

	UPROPERTY(EditDefaultsOnly, Category = "PlayerCameraManager")
	float FirstPersonDistance;


Hey -

I still have not been able to reproduce the sound playing twice. If possible could you send me the full header and source for your camera and player controller? You can send me a private message on the for security if you would rather not post the files here.


Hey h2o-

Trying to use the class files you sent produced compile errors due to other missing files (InventoryItem class). Could you send me the current project to test directly?

i will sent you wia forum again. tnx

The project you sent on the seems to be a very large project and will crash as I click play. Can you reproduce the sound playing twice in a new project and if so can you list the steps used to cause it in that project or send us the smaller project?

Hey -

After testing the project again I did not hear audio playing twice (texted with the rocket launcher and machine gun). However while testing the weapons I noticed that the log gave a warning about spatialization and multichannel sounds not supported. Following this warning back I found that the WeaponShot_att asset had its Spatialize checkbox set to true. Setting this to false fixed the warning messages. I can’t say for sure but this may help with the sound playing twice. If you are trying to use spatialization then you can check out this wiki link to make sure that it is setup properly.


Hello, tnx for testing it. it is still there, please try to zoom out camera after you press V after shot and you will hear it, i have just tested it. I can make a video with sound for you if you wish.

And i will check settings you pointed me, tnx

Hey -

Using after zooming out as you suggested I was able to hear the sound playing a second time. I’ve entered a bug report for this (UE-19781) for further investigation.