Please help!
I have a player game object (controls script attached) that has 2 child objects (only 1 of which is enabled depending on being a local or remote client).
If the local child is enabled, this has a child called “Engines” which in turn has 2 children for left and right engines. These 2 child objects have an audiosource that plays the sound.
How do I access the pitch of these audiosources from within the player object that handles the controls?
I have googled and searched but have been left confused by it all as the audiosources are for want of a better description, great grandchildren of the player object.
I thought the following c# code would do it but it doesn’t…it may help clarify what I’m after though
GameObject playerChild = GameObject.Find("LocalSHIP");
GameObject engineAudio = playerChild.Find("Engines");
GameObject engineAudioL = engineAudio.Find("EngineLeft");
AudioSource EngineL = engineAudioL.GetComponent<AudioSource> ();
EngineL.pitch = enginePowerValue;
EngineLeft is the child of engines which is the child of localSHIP which is the child of PlayerSHIP
Thanks for looking if nothing else