Game Development Community

Playing a sound on the client, called by the server

by Bryce · in Technical Issues · 11/10/2007 (10:03 pm) · 6 replies

Okay.

My situation is how to get a sound to play on a client that I choose. I have an AI Player perched up in a tower with a rocket-propelled grenade launcher. When he fires a rocket at me, and it hits nearby and wounds me, I want to play a 2D sound on the client of every player that got hurt. Is this clear for everyone to understand?

#1
11/11/2007 (2:14 am)
Well, I think I understand. In this specific case, I believe the sounds are created via the projectile explosion datablock, as long as you've chosen 3d sound for that object.
#2
11/11/2007 (8:12 pm)
No, I mean that every player caught in the explosion hears a 2D sound, but nobody else.
#3
11/11/2007 (10:15 pm)
You could extend the radiusDamage function which is use by your projectile's onCollision function to play a sound for those clients beeing hurt. Use ServerPlay2D function then, not ServerPlay3D as 3D would be heard by all those guys around and 2D only for those who got the message. Does that help?
#4
11/12/2007 (6:43 am)
How would I call that though in radiusDamage()? Like this?

if (%ringEars && %targetObj.client)
{
    %targetObj.client.serverPlay2D("RingEarsSound2D"); // target object being the object hit by the radius damage

    // ---OR LIKE THIS??---

    serverPlay2D(%targetObj.client,"RingEarsSound2D");
}
#5
11/12/2007 (6:45 am)
If I recall the serverPlay2D right, the second one.
#6
12/26/2007 (4:21 am)
Got it.
serverPlayer2D("RingEarsSound2D",%targetObj.client);