Closed citron4000 closed 7 years ago
I want to have the PlaybackPrefab at the right place in space after the player is spawned
Dissonance position tracking does do this for you. It creates an invisible game object at the correct position and attaches the playback prefab to it. I haven't tested this with the Oculus Audio Spatializer specifically but it should just work(tm). The general idea is that you don't need to worry about the playback prefab at all - as long as you attach the DissonancePlayer components to the right entity all the audio will be synchronised in the correct position.
I have a few more questions about this error:
Thanks for the reply.
You are right the Audio Spatializer from Oculus would work on the PlayerPrefab without problem using Dissonance positional audio (it works with any AudioSource). However, even though the gain in bandwidth might be insignificant, putting the PlaybackPrefab under the player allows us to save the positional audio data send from Dissonance since we are syncing the player anyway. We are also planning to move the PlaybackPrefab in other positions on our own depending on the player's action so that is why we would prefer to manage this part ourselves.
About your questions:
Yes we do have this object in the first place when a client connects.
I actually do not create a PlaybackPrefab myself, I let Dissonance do it and then I manually add it (with a script) under the remote player when it has connected.
Thanks again
Dissonance already handles the situation you describe. Rather than move the PlaybackPrefab
under your remote player entities, you should instead attach a DissonancePlayer
script to each remote player entity and set the PlayerId
to that of the relevant player. Dissonance will then mirror the position of this entity for you.
If you are using the Unity HLAPI for networking, you can use HlapiPlayer
instead, which will wire the player ID automatically.
Currently, we do not send player position over the network ourselves. We rely on the user having an entity for each remote player in their scene and keeping its position in sync themselves, under the assumption that the game is probably already doing this.
Okay, that sounds good, thanks for your time on this, I'll change it on our side.
So the positional tracking works well and moves with the player. However, I think it is fairly common in VR games to first spawn a first Player then spawn a separate object for the head and and then objects for the two hands and give it client authority. In this case, if we only attach the PlaybackPrefab to the Player (and not the head), we don't have the rotation and position of the head which might be important for some audio spatialiser. Of course the base Player could reflect the head tracking but I think that wouldn't be a very elegant solution.
What is your thoughts on that? Would it be possible to attach the PlaybackPrefab to other objects besides the Player?
Ultimately Dissonance just needs a component which implements the IDissonancePlayer
interface passed into DissonanceComms:StartTracking
. The HlapiPlayer class (which implements this interface for you) relies on the NetworkBehaviour.isLocalPlayer
and returns the transform of whatever it is attached to. I guess this won't work because the body is the local player, but you want the transform from some other object (i.e. the head).
I think you're going to need to write your own IDissonancePlayer
implementation (this is pretty simple, you can probably start by copying HlapiPlayer and adapting it to your needs). The two ways it sounds like you could do this:
isLocalPlayer
use localPlayerAuthority
. Then return transform information from the head object.isLocalPlayer
. In the Position
and Rotation
properties instead of returning the local transform, find the head object and return it's transform.Unfortunately we don't have any decent documentation on this (that's a serious oversight I'll be fixing today). So feel free to ask if you need help implementing that :)
I have written some additional documentation to do with IDissonancePlayer: https://dissonance.readthedocs.io/en/latest/Tutorials/Custom-Position-Tracking/.
If you're still having problems I suggest opening another issue :)
If your player head is part of the player prefab that unity is instantiating for each local and remote player, then you should be able to move it onto the head.
This is assuming that Unity marks children of the player as also being local to the player, which is not something I've tested.
Many thanks for your help.
Hello,
I am using Dissonance for a VR project and will use the Oculus Audio Spatializer. So I want to have the PlaybackPrefab at the right place in space after the player is spawned, I place the PlaybackPrefab under the remote clients camera. I think this is a better way than to use Dissonance Audio Positioning.
When one of the client disconnect, the remote client is destroyed along with the PlaybackPrefab which is a child of the player. Then I get an error:
It might not be a bug per say but maybe adding a few check to see if the Playback prefab is null is possible.. what do you think?
Thanks!