- Home /
Audio in online game
Hi, I'm developing a simple third person online shooter with an non-authoritative server. I've synchronized players and projectile view. For now each player listen fire effects of each other players in the scene. How can I make listen to player only sound effects of fire and projectile in the near or at least make listen only sound effects of fire that are in the camera view? This is the code of fire RPC:
function Update { if( Input.GetButtonDown( "Fire1" )) { var viewID : NetworkViewID= Network.AllocateViewID(); networkView.RPC("Fire", RPCMode.AllBuffered, viewID, transform.position); } }
@RPC function Fire (viewID : NetworkViewID, location : Vector3) { // Instantate the prefab locally var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation ); instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) ); AudioSource.PlayClipAtPoint(bulletClip, transform.position); Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider); Destroy(instantiatedProjectile.gameObject, 1); var nView : NetworkView; nView = instantiatedProjectile.GetComponent(NetworkView); nView.viewID = viewID; }
I try to make the AudioClip as 3D audio but I don't hear the clip anymore
Your answer
Follow this Question
Related Questions
Projectile in online multiplayer 1 Answer
Top down shooter trajectory 1 Answer
Need urgent help to create projectile shooting script with raycasting 1 Answer
2D top down projectile with joystick problem 1 Answer
Online TPS problem 1 Answer