UE4 plugin is spamming the log with "Forward vector { -0.812378, 0, 8.23165e-07 } is not a unit vector."

Hi, our sound guy just added FMOD to our UE4 project & we’re getting a load of these errors spamming the output log:

LogFMOD: Warning: e:\jk\workspace\2.1_UE4.23_Win64\core_api\src\fmod_3d.h(339) - Forward vector { -0.812378, 0, 8.23165e-07 } is not a unit vector.

I can’t seem to find fmod_3d.h anywhere in the plugin directory so I’m guessing that it’s something in one of the dll files? Any way to fix this? I guess I can turn off LogFMOD completely but, like, what’s up with this?

fmod_3d.h is internal to the DLL.

When passing forward and up vectors to FMOD they must be of unit length (1.0f).
Are you setting these vectors or is something within FMOD / UE4 setting them?

We’ve literally only just added the plugin to the project. Or rather our sound guy did and I’m merging his changes in. I don’t think he’s added any sounds yet or actually done anything that would involve vectors at all. Will check though. I understand what the error is trying to say, but no idea how to track down where this supposed vector is coming from. Had assumed it was being defined by something internal to FMOD or the plugin but I’m guessing there’s no way to fix it if that were the case?

That message can only come from setting the 3D attributes of a listener or of an event instance.

Wherever the integration sets the 3D attributes of a listener or an event instance we extract the orientation vectors from a UE4 FTransform using FTransform::GetUnitAxis which should always be returning unit vectors. The integration doesn’t validate that the vectors we get from UE4 are unit vectors before passing them to the FMOD API so it would pass a non-unit vector through to the API and trigger the warning message you are seeing. So unless you have other code in your project which is directly calling FMOD::Studio::System::setListenerAttributes or FMOD::Studio::EventInstance::set3DAttributes, then it seems you have a situation where FTransform::GetUnitAxis is returning a non-unit vector to our integration.

I will add an issue to our tracker to improve this. Because the vectors we use are extracted from UE4 data we would not be able to prevent non-unit vectors being produced, but validating and logging the vectors in the integration code should make it easier to understand and track down the source of the issue. In the meantime if you are comfortable with modifying the integration source code you could add validation and logging yourself.

There are three places where FMOD::Studio::EventInstance::set3DAttributes is called where non-unit vectors coming from UE4 would be passed through to our API and generate that warning:

  1. UFMODAudioComponent::OnUpdateTransform in FMODAudioComponent.cpp
  2. UFMODBlueprintStatics::PlayEventAtLocation in FMODBlueprintStatics.cpp
  3. UFMODBlueprintStatics::EventInstanceSetTransform in FMODBlueprintStatics.cpp

And two places where FMOD::Studio::System::setListenerAttributes is called:

  1. FFMODStudioModule::SetListenerPosition in FMODStudioModule.cpp
  2. FFMODStudioEditorModule::Tick in FMODStudioEditorModule.cpp

Thank you, that’s really helpful. Hopefully that will allow me to track down the offending vector & will report back if so.

Ok, so spent some time looking in to this to see if it was related to another issue. Since I’m getting so many messages I’m fairly certain that the offending call is tick-related, which would likely make it the last one on your list:
FFMODStudioEditorModule::Tick in FMODStudioEditorModule.cpp
This appears get the camera position and orientation which it then passes to the FMOD SoundSystem. To verify, if I move the camera in the editor, I can see the error message changing with new vectors (which are also not unit vectors). Sometimes it complains about the Forward vector, sometimes it’s the Up vector. The code in question looks like it should be creating unit vectors, so it’s not clear why it’s not getting them. I’ve manually checked the vector lengths and they’re way off, like 0.65 for example so it’s not a mismatch in expectations around accuracy.

However, this seems to only happen on my PC, not on my Mac, or on any of my colleague’s PCs. I’ve been trying to track down another non-sensical bug in a completely unrelated part of the code which only appears on that computer (and I’ve confirmed the other bug’s behaviour was first introduced in the commits that added FMOD to the project) so I’m worried that there may be some nasty hard to track down memory corruption going on somewhere?

Think I might go a full wipe of the project and UE4 on that PC and set it all up again from scratch to see if something esoteric has snuck in somehow… Otherwise I’m a bit lost again!

That is odd. For now it doesn’t seem there’s anything we can follow up on our side but please ask if you have any questions for us, we’re always happy to help. Otherwise let us know how you go after cleaning out, if you’re still hitting the issue we can work with you to dig into it further.

Good news! Managed to get to the bottom of the issue. Turns out there was a compiler bug in the version of visual studio I was using. Lead to vector calculations being inaccurate in some edge cases. Updating to the latest version of VS fixed everything right up. :+1:

1 Like