diff --git a/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp b/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp index 4398f169da874689f1d920935296e7359c4bde1a..f18c61972a5ab5edc6e95e0d791c5b2ae09e0ff3 100644 --- a/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp +++ b/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp @@ -8,6 +8,7 @@ #include "SoundSource/VASoundSourceRepresentation.h" #include "Engine/World.h" +#include "Utility/VirtualRealityUtilities.h" // ****************************************************************** // @@ -73,7 +74,7 @@ void FVASoundSource::SetPosition(const FVector NewPosition) { Position = NewPosition; - if (!FVAPlugin::SetSoundSourcePosition(SoundSourceID, Position)) + if (!FVAPlugin::SetSoundSourcePosition(SoundSourceID, Position) && UVirtualRealityUtilities::IsMaster()) { FVAUtils::LogStuff("[FVASoundSource::SetPosition()]:" + FString(" Could not set sound source position in VA. Position of visual and auditive representation might mismatch now."), true); @@ -86,7 +87,7 @@ void FVASoundSource::SetRotation(const FRotator NewRotation) { Rotation = NewRotation; - if (!FVAPlugin::SetSoundSourceRotation(SoundSourceID, Rotation)) + if (!FVAPlugin::SetSoundSourceRotation(SoundSourceID, Rotation) && UVirtualRealityUtilities::IsMaster()) { FVAUtils::LogStuff("[FVASoundSource::SetRotation()]:" + FString(" Could not set sound source rotation in VA. Orientation of visual and auditive representation might mismatch now."), true); diff --git a/Source/VAPlugin/Private/VAReceiverActor.cpp b/Source/VAPlugin/Private/VAReceiverActor.cpp index 467a79f5c2dbf276369504751181246966b22e7c..3505eda61bd636786f58b547f5a761e6f9d013a3 100644 --- a/Source/VAPlugin/Private/VAReceiverActor.cpp +++ b/Source/VAPlugin/Private/VAReceiverActor.cpp @@ -257,13 +257,28 @@ bool AVAReceiverActor::UpdateVirtualWorldPose() if(TrackingSource == ETrackingSource::VirtualRealityPawn) { - // Auralization Pose is coppled to the Virtual Reality Pawn, e.g, HMD, CAVE - FVector ViewPos; - FRotator ViewRot; - GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(ViewPos, ViewRot); + // Auralization Pose is coupled to the Virtual Reality Pawn, e.g, HMD, CAVE + + AVirtualRealityPawn* VirtualRealityPawn = Cast<AVirtualRealityPawn>(GetWorld()->GetFirstPlayerController()->AcknowledgedPawn); + if (VirtualRealityPawn == nullptr) + { + return false; + } + + USceneComponent* Head = VirtualRealityPawn->Head; + + if (!Head) + { + return false; + } + + FVector ViewPos = Head->GetComponentLocation(); + FRotator ViewRot = Head->GetComponentRotation(); + //Offset from ViewPoint (between eyes) to head center, rotate according to view rotation + ViewPos += ViewRot.RotateVector(ViewpointToHeadcenterOffset); bool bResult = true; - bResult &= FVAPlugin::SetSoundReceiverPosition(ReceiverID, ViewPos + ViewRot.RotateVector(ViewpointToHeadcenterOffset)); //Offset from ViewPoint (between eyes) to head center, rotate according to view rotation + bResult &= FVAPlugin::SetSoundReceiverPosition(ReceiverID, ViewPos); bResult &= FVAPlugin::SetSoundReceiverRotation(ReceiverID, ViewRot); return bResult; }