Remove Audio Source from EntitySolved

Hey there,

i'm trying to delete an audioSource (CargoPlane) but i got a convert exception:
Argument #1 cannot convert to expression to type UnityEngine.Object

var sound = p.GetComponent<AudioSource>();
if(sound != null)
{
      UnityEngine.Object.DestroyImmediate(sound);
}​

I've tested it with UnityEngine.AudioSource.DestroyImmediate() but it ends in a `.` operator cannot be applied to operand of type UnityEngine.AudioSource.

What i want is simple: Removing the CargoPlane Engine sound. Removing the CargoPlane Component doesn't stop the sound.

Any ideas?

Thanks :)

Could you show us what "p" is?

CargoPlane

Those are probably client side. Lots of code is shared so sometimes you will find dead code in the server. Some sounds are automatically emitted for certain entities in certain states, which you can't do anything about other than not networking the entity or the particular attributes of it.

The main way you can block sounds on the server are when they are played via a direct networked effect. I haven't looked at the Cargo Plane code, but I'm guessing it doesn't use effects, so you probably can't make the planes silent without hiding them.

Oc6dPCPFVlVXcI0.jpg WhiteThunder

Those are probably client side. Lots of code is shared so sometimes you will find dead code in the server. Some sounds are automatically emitted for certain entities in certain states, which you can't do anything about other than not networking the entity or the particular attributes of it.

The main way you can block sounds on the server are when they are played via a direct networked effect. I haven't looked at the Cargo Plane code, but I'm guessing it doesn't use effects, so you probably can't make the planes silent without hiding them.

Mhh, Okay thanks for the reply and the info :)

Locked automatically