Game Development Community

Confused about sound and music play (server or client?)

by weihua · in Torque 3D Professional · 05/16/2010 (5:28 am) · 6 replies

I think playing sound and music is a client job.
I am confused why audio.cs and audioDescription.cs are executed on server side (in the examples of the SDK)?
Is that for some specific purpose?
Thanks!

#1
05/17/2010 (1:24 pm)
Not to be a prat but...

audio.cs
//-----------------------------------------------------------------------------
// Torque Shader Engine 
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

function ServerPlay2D(%profile)
{
   // Play the given sound profile on every client.
   // The sounds will be transmitted as an event, not attached to any object.
   for(%idx = 0; %idx < ClientGroup.getCount(); %idx++)
      ClientGroup.getObject(%idx).play2D(%profile);
}

function ServerPlay3D(%profile,%transform)
{
   // Play the given sound profile at the given position on every client
   // The sound will be transmitted as an event, not attached to any object.
   for(%idx = 0; %idx < ClientGroup.getCount(); %idx++)
      ClientGroup.getObject(%idx).play3D(%profile,%transform);
}

If you read the comments tt's not actually playing the sound it's just sending the command to play the sound.

Now audioDescriptions.cs is just in the core/art/datablocks folder and I believe is running on the clients.

Some one feel free to correct me if I'm wrong about that.
#2
05/17/2010 (5:36 pm)
audioDescriptions.cs is not running on the client side. I set a break point on this line: "exec("./audioDescriptions.cs");" in datablockExec.cs. It is never executed on the client.
But if you comment this line, a lot of SFXProfile((null)) error will be reported on the client side.
I think the sound profile might be treated as a net object and should be transmitted to the client.
#3
05/18/2010 (4:17 am)
When I set a break point audioDescriptions.cs is loading just as soon as you hit "Go" from the misson chooser on a Blank Full Template.
#4
05/19/2010 (8:28 pm)
Yes, but if you select join game. That line will never be reached. So it won't be executed on client side.
#5
05/20/2010 (12:17 am)
The audioDescriptions behave the same way as normal datablocks, and are loaded on the server and then transmitted to the clients.

Despite the fact that the relevant files are located in a directory under /client, they are actually needed by the server as without them the server cannot load any datablock which refers to an audiodescription (like the players, weapons etc).

#6
05/21/2010 (2:19 am)
Thanks you Allard :-)
That's clear.