How would i go about implementing some sort of Audio based chat for multiplayer?
assuming id need a audio source coming from each player joined.
then somehow linking it to a mic… hmm
any clues?
How would i go about implementing some sort of Audio based chat for multiplayer?
assuming id need a audio source coming from each player joined.
then somehow linking it to a mic… hmm
any clues?
I figure you’d start it off like this
@RPC
function PlayMicrophone()
{
audio.clip = Microphone.Start("", true, 100, 44100);
audio.loop = true;
while (!(Microphone.GetPosition("") > 0)){}
audio.Play();
}
Then add it to a function thats starts a server or when a player joins a server.
function OnServerInitialized()
{
networkView.RPC("PlayMicrophone", RPCMode.Others);
}
function OnConnectedToServer()
{
networkView.RPC("PlayMicrophone", RPCMode.Others);
}
Something like that anyways.
Hey @Lepp I've tried out your script, but I only here myself echo though the same application, others can't here me. Have any clues? Thanks.
– Mortise@Mortise Yeah this was never meant to be a complete answer only a push in the right direction and it's probably changed some you'll have to do some searching. @Zoelovezle Not really sure if this was obsolete 2 years ago, but hey what do I know. Also would like to note that I originally put this as a comment on the OP not as an answer. =p
– LeppYou mean like make the arrow point at a target instead of the direction it is traveling? This would look very unrealistic and messy. I advise you just add the appropriate amount of force to the arrow to make it travel towards the target, thus making it face the target and travel towards it.
– TapeAfter a year of game development I have come to one conclusion. Unity does not directly provide the tools for voice chat. You have to use external software, plugins, extensions, or manually edit the coding unity allows you to edit which is extremely hard:(. Voice chat (I don’t think is on the asset store anymore) and uspeak are two of the only voice chat systems on the asset store and both use plugins.
The problem with worldowar1’s script is that the audio clip he is attempting to play over the network is not available over the network meaning that you may have the audio on your instance to play, but if somebody else is playing elsewhere that audio clip that you are telling them to play via rpc they will not have in their instance which avoids the whole entire problems and difficulties of voice chat. This explains you hearing yourself because you have the audio, and explains others not hearing the audio playing because they do not have YOUR clip that you recorded which can even cause others instance of the game to crash. If you can somehow modify a base audio recording using integers floats strings or booleans( super complex and maybe not worth time effort and having a huge cost to the efficiency of your game) from your recording like a whole nother language. Pretty much changing a rock into dust sending it and putting the dust particles back together. Rpcs can only send floats integers strings and booleans not audio recordings. If you want to do recording unless you are a boss scientist/mathematician and figure out away to convert speech into numbers or text send all that to somebody else without lag effecting your game and for them to convert those numbers slash text back into speech it is not doable through the given tools unity gives you unless you edit the editor code(hard). I highly suggest looking into plugins and using another software to do this. If you want to try my conversion method I will be happy to join you it will be a good science fair experiment for me. I can go a lot deeper into this but I just want to give you a basic level. But this is not simple stuff.thanks
So in other words (if I remember right you can use system api's in unity) you would take the pcm data from the recorded audio of one client, send the values over unitys networking and reconstruct it on another client? =p Trying to get a better picture of what you're trying to explain. Also you got me curious.
– Lepp© 2022 - 2024 — McMap. All rights reserved.
try this: http://docs.unity3d.com/Documentation/ScriptReference/Microphone.html http://docs.unity3d.com/Documentation/ScriptReference/Network.html
– Constrictdo you have any clue alucardj?
– JeffriesNo, sorry. Also curious so am following this question. I mean sure, [Microphone.Start][1] starts recording with built-in Microphone and plays the recorded audio right away, but how to play and sync that audio across all networked clients? [1]: http://docs.unity3d.com/Documentation/ScriptReference/Microphone.Start.html
– Maibleperhaps. I could try that :)
– JeffriesI haven't been able to play around with it too much, I've been working with a database that's being a pain. xD If I find out a specific way to set it up I'll post back what I find.
– Lepp