Questions in topic: "sounds"http://answers.unity.com/questions/topics/single/3254.html
The latest questions for the topic "sounds"when i change the platform to weBGL the sound of my game Disappeared please help me,when I change the platform to weBGL the sound of my game Disappeared please help mehttp://answers.unity.com/questions/1630621/when-i-change-the-platform-to-webgl-the-sound-of-m.html
it's work just fine in pc,mac platform but when I switch it, the sound DisappearedsoundsSat, 11 May 2019 20:19:13 GMTremdanehow to get ingame sound in headset and spotify on monitor?http://answers.unity.com/questions/1622013/how-to-get-ingame-sound-in-headset-and-spotify-on.html
i would like to listen to diffrent thing but spotify on monitor spreajers and ingame sound in my headsetsoundsSun, 14 Apr 2019 07:09:06 GMTdanielcarlsen123footstep sound and velocities / sonidos de pasos y velocidadeshttp://answers.unity.com/questions/1619654/footstep-sound-and-velocities-sonidos-de-pasos-y-v.html
Buenas! mi problema es el siguiente:
Tengo mi script de movimiento con sus respectivos sonidos, estos son: Correr, caminar, sprintar y apuntar. Hasta ahi bien, mi propblema llega cuando algunos de estos sonidos no se reproducen pero si que cambian sus respectivas velocidades de movimiento (apuntando llevas una velocidad, corriendo otra...), o no cambian las velocidades y solo algunos se oyen... y ya estoy desquiciado! A ver si alguien puede echarme una manilla!!! Un saludo! (no soy muy buen programador lo digo de antemano jeje)
Adjunto los dos scripts en cuestion
Movimiento con sonidos :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float WalkSpeed, Sprintspeed;
private CharacterController character_controller;
private Vector3 moveDirection;
public float speed = 4f;
private float gravity = 20f;
public float jumpForce = 10f;
private float verticalVelocity;
public bool IsWalking, IsSprinting, IsAiming;
public Animator animator;
public float Hor, Ver;
private PlayerFootsteps playerFootsteps;
private float sprint_volume = 1f;
private float crouch_volume = 0.1f;
private float walk_volume_min = 0.2f, walk_volume_Max = 0.6f;
private float walkStepDistance = 0.3f;
private float sprintStepDistance = 0.25f;
private float crouchStepDistance = 0.5f;
private void Awake()
{
playerFootsteps = GetComponentInChildren<PlayerFootsteps>();
character_controller = GetComponent<CharacterController>();
animator = GetComponentInChildren<Animator>();
}
// Start is called before the first frame update
void Start()
{
playerFootsteps.volumeMin = walk_volume_min;
playerFootsteps.VolumeMax = walk_volume_Max;
playerFootsteps.stepDistance = walkStepDistance;
}
// Update is called once per frame
void Update()
{
MoveThePlayer();
}
void LateUpdate()
{
speed = 4;
Apuntar();
Sprintar();
Caminar();
}
void MoveThePlayer()
{
float Hor = Input.GetAxis("Horizontal");
float Ver = Input.GetAxis("Vertical");
moveDirection = new Vector3(Hor, 0f, Ver);
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed * Time.deltaTime;
ApplyGravity();
character_controller.Move(moveDirection);
animator.SetFloat("VelocityRight", Hor);
animator.SetFloat("VelocityForward", Ver);
}
void ApplyGravity()
{
verticalVelocity -= gravity * Time.deltaTime;
PlayerJump();
moveDirection.y = verticalVelocity * Time.deltaTime;
}
void PlayerJump()
{
if(character_controller.isGrounded && Input.GetKeyDown(KeyCode.Space))
{
verticalVelocity = jumpForce;
}
}
void Apuntar()
{
if (Input.GetMouseButton(1))
{
IsAiming = true;
speed = WalkSpeed;
playerFootsteps.stepDistance = crouchStepDistance;
playerFootsteps.volumeMin = crouch_volume;
playerFootsteps.VolumeMax = crouch_volume;
animator.SetBool("IsAiming", true);
animator.SetBool("IsWalking", false);
animator.SetBool("IsSprinting", false);
}
else
{
IsAiming = false;
playerFootsteps.stepDistance = walkStepDistance;
playerFootsteps.volumeMin = walk_volume_min;
playerFootsteps.VolumeMax = walk_volume_Max;
animator.SetBool("IsAiming", false);
}
}
void Sprintar()
{
if (Input.GetKey(KeyCode.LeftShift) && IsAiming == false)
{
IsSprinting = true;
speed = Sprintspeed;
playerFootsteps.stepDistance = sprintStepDistance;
playerFootsteps.volumeMin = sprint_volume;
playerFootsteps.VolumeMax = sprint_volume;
animator.SetBool("IsSprinting", true);
}
else
{
IsSprinting = false;
playerFootsteps.stepDistance = walkStepDistance;
playerFootsteps.volumeMin = walk_volume_min;
playerFootsteps.VolumeMax = walk_volume_Max;
animator.SetBool("IsSprinting", false);
}
}
void Caminar()
{
if (Input.GetKey(KeyCode.LeftControl))
{
IsWalking = true;
speed = WalkSpeed;
playerFootsteps.stepDistance = crouchStepDistance;
playerFootsteps.volumeMin = crouch_volume;
playerFootsteps.VolumeMax = crouch_volume;
animator.SetBool("IsWalking", true);
}
else
{
IsWalking = false;
playerFootsteps.stepDistance = walkStepDistance;
playerFootsteps.volumeMin = walk_volume_min;
playerFootsteps.VolumeMax = walk_volume_Max;
animator.SetBool("IsWalking", false);
}
}
}
Script para añadir sonidos:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerFootsteps : MonoBehaviour
{
private AudioSource footstepSound;
[SerializeField]
private AudioClip[] footstepClip;
private CharacterController characterController;
[HideInInspector]
public float volumeMin, VolumeMax;
private float accumulatedDistance;
[HideInInspector]
public float stepDistance;
// Start is called before the first frame update
void Awake()
{
footstepSound = GetComponent<AudioSource>();
characterController = GetComponentInParent<CharacterController>();
}
// Update is called once per frame
void Update()
{
CheckToPlayFootstepSound();
}
void CheckToPlayFootstepSound()
{
if (!characterController.isGrounded)
return;
if(characterController.velocity.sqrMagnitude > 0)
{
accumulatedDistance += Time.deltaTime;
if(accumulatedDistance > stepDistance)
{
footstepSound.volume = Random.Range(volumeMin, VolumeMax);
footstepSound.clip = footstepClip[Random.Range(0, footstepClip.Length)];
footstepSound.Play();
accumulatedDistance = 0f;
}
}
else
{
accumulatedDistance = 0f;
}
}
}velocitymovement scriptsoundsSat, 06 Apr 2019 21:39:22 GMTDariocerHearing sound outside of maximum rangehttp://answers.unity.com/questions/1607267/hearing-sound-outside-of-maximum-range.html
So I had a problem lately where I can hear a sound outside of it's maximum range, I can be anywhere on the map yet it still plays, maximum distance is set to 7, I do have spatial blend on 1 and I do have costum rolloff. I tried everything and nothing workssoundsThu, 28 Feb 2019 08:42:52 GMTd4vscr1ptSeveral audiosources play at the same timehttp://answers.unity.com/questions/1601214/several-audiosources-play-at-the-same-time.html
I have scripts that includes audio. This one is attached to an enemy and would follow the player. I want to play audio at the same time, but there are too many audios playing at the same time, so the noise is sharp and unclear.
***
This is my script:
---
void FollowPlayer()
{
closestplayer = GameObject.FindGameObjectWithTag(PlayerTag);
gameObject.transform.position = Vector2.MoveTowards(transform.position, GameObject.FindGameObjectWithTag(PlayerTag).transform.position, EnemySpeed * Time.deltaTime);
AudioSource.PlayClipAtPoint(MoveClip, transform.position);
}
The MoveClip is a clip that plays when moving(Foot steps).
**
What is wrong in my script?
Here are some Images:
**
This is what happens when I start the game:
![alt text][1]
[1]: /storage/temp/133045-2019-02-12.png
**
Can anyone help me please?! Thank you!audioaudiosourceaudioclipsoundsmanyWed, 13 Feb 2019 00:33:09 GMTTommyflyHow can I make my enemy detect and Run towards sound?http://answers.unity.com/questions/1589410/how-i-can-make-my-enemy-go-towards-soundhow-can-i.html
I am making a Horror Game and I need my Enemy to Run Towards a specific sound (e.x. I open a door and i make noise, enemy detects the sound and Runs towards that door.).
sorry for my bad English ;)movementtriggersoundenemy aisoundsSat, 12 Jan 2019 15:23:59 GMTninjarosound delayhttp://answers.unity.com/questions/1588659/sound-delay-1.html
Hi,I'm working on my game project but a have a problem. Game When running on unity engine game sounds are pretty good. But when game is running on android game sounds coming a little bit delay like a 0.5 second. can anybody helpsoundsThu, 10 Jan 2019 13:24:10 GMTfatihcylnPrefab button not loading soundhttp://answers.unity.com/questions/1584845/prefab-button-not-loading-sound.html
Hi,
I am working on a game which has a prefab button. A button needs to have a sound played when clicked.
I have a gameObject named SoundManager with all the necessary sounds.
But when I make that button a prefab, the assigned gameObject disappears.
I cannot even able to assign it manually.
What should I do?
Please help I am new to Unity.prefabssoundsSat, 29 Dec 2018 14:42:39 GMTkarjivPlay test sound when slider's value is changed and mouse button got released.http://answers.unity.com/questions/1583551/play-test-sound-when-sliders-value-is-changed-and.html
Hey,
So I want to play test sound every time user sets a new volume and releases mouse button.
I know, I know, there is a post about it here:
https://answers.unity.com/questions/1086706/volume-slider-play-a-sound-after-modifying-slider.html
but I can't understand it, how to do it. I tried and I think I was wrong or something.
The sound didn't play. I set the sound source, sound clip etc. Also I checked my volume in Windows and it was okay nothing muted. "Mute Audio" in the editor runtime window wasn't checked. I just can't understand how to do it...soundslidervolumesoundsSun, 23 Dec 2018 21:36:00 GMTAspect13How can I get indiviual file out of a unity package?http://answers.unity.com/questions/1566999/how-can-i-get-indiviual-file-out-of-a-unity-packag.html
<p>I recently got a sound effect package from the asset store. </p>
<br>
<p>I want to be able to listen to individual tracks and import those that I need to use. However, I didn't find a way to get the individual file.</p>
<br>
<p>I don't want to import the whole package into my project since it can make the project really big and slow to open.</p>
<br>
Can anyone tell me how to do that, other than do the selections from the package import window?importpackagesoundspackagessound effectsTue, 30 Oct 2018 03:25:49 GMTZ_Peiplay sound after destroy the enemy by taghttp://answers.unity.com/questions/1566458/play-sound-after-destroy-the-enemy-by-tag.html
i'm trying to play sound after completely destroy all enemies in the game to tell the player you have won by voice, so I tried code but it is not. so, I need other code that help me to achieve my purpose.playerdestroyenemysoundsoundsSun, 28 Oct 2018 04:54:12 GMTKhalidrashdizx933D audio sources Harsh Panning problemhttp://answers.unity.com/questions/1560026/3d-audio-sources-harsh-panning-problem.html
In a 2D project I am using a mono audio source in 3D and everything is working correctly except the panning. There seems to be no controllable curve for panning intensity? This results in harsh switching between left and right when the listener passes the audio source.
Example: When the listener is to the right of the source the volume in the left channel is much louder (as it should be) but there is almost no volume in the right channel. As you move closer the right channel only increases in volume slightly, until you pass the source, where it then flips drastically to loud volume in the right channel and little in the left.
Am I missing something? I can't find a curve or slider to adjust this?audioaudiosourcesoundspanningFri, 05 Oct 2018 18:11:52 GMTcalminthenightwww.GetAudioClip() get song and play 3s after game start.http://answers.unity.com/questions/1550603/wwwgetaudioclip-get-song-and-play-3s-after-game-st.html
I use www.GetAudioClip() to get song and play when game (Android mobile game) start. my issue is it get 3s delay to play song. My suggest is add some loading screen before start game and game start after www.GetAudioClip() get song and play. its there any way to play song same time that game start?? i'm new to unity3D .if some can help me with this. It's big help . Thanks SupunsoundsFri, 07 Sep 2018 06:36:44 GMTsupun_unityWhy does my background sound fade when other sounds are being played?http://answers.unity.com/questions/1549528/why-does-my-background-sound-fade-when-other-sound.html
Hello, i have a level, a scene that is where the background contains lava, so i put a sound of lava in the scene, however, when i shoot my gun or walk or do anything that triggers another sound, the lava sound fades, i have put priority of the sound to HIGH (0 that is) and this still happens, sorry for my lack of knowledge in unity sound editing, im new to all this? THANKS!triggersoundsbackground musicTue, 04 Sep 2018 12:04:17 GMTsmarjanovicngMaking Enemy Audio quieterhttp://answers.unity.com/questions/1546903/making-enemy-audio-quieter.html
How do I make the audio from a enemy fade away as i move further away from it?
I've tried to use the 3D sound settings in the audio source but the enemy audio is the same no matter how far away it is from the playersoundsoundssound effectsfadeoutfadeinMon, 27 Aug 2018 17:19:10 GMTNosmoButtons sounds are only playing once, then the sound no longer plays?http://answers.unity.com/questions/1546056/buttons-sounds-are-only-playing-once-then-the-soun.html
I have created an Audio Assistant script and then I call from the script with another script to make sounds become active on button clicks. However, once the button is clicked again, the sound no longer plays.
----------
Here is the script that I am calling the sound to activate on multiple buttons:
----------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class ButtonSoundGamePlay : MonoBehaviour {
public void GeneralButtonClick()
{
AudioAssistant.Shot("GeneralButton");
}
public void StoreButtonClick()
{
AudioAssistant.Shot("StoreButton");
}
public void BuyButtonCoinClick()
{
AudioAssistant.Shot("BuyButtonCoin");
}
public void BuyButtonPowerClick()
{
AudioAssistant.Shot("BuyButtonPower");
}
public void PowerSetButtonClick()
{
AudioAssistant.Shot("PowerSetButton");
}
public void StoreReturnButtonClick()
{
AudioAssistant.Shot("StoreReturnButton");
}
public void ExitButtonClick()
{
AudioAssistant.Shot("ExitButton");
}
public void RakeButtonSoundClick()
{
AudioAssistant.Shot("RakeButtonSound");
}
}
----------
The buttons are assigned with each function and each sound is set in the Audio Assistant script. Any ideas would be very helpful. Thanks.c#buttonaudiofunctionssoundsSat, 25 Aug 2018 02:10:22 GMTGovqtrpetpFirework Soundshttp://answers.unity.com/questions/1535777/firework-sounds.html
I have a particle for fireworks (Unity's Standard Assets). And I want to add sounds when a firework is spawned and blows up. How do I do that?
**EDIT:** I can't figure out how to detect firework explosions. That's my problem. I have everything, Sounds, AudioManager. But I can't figure out how to detect when the particle is born and diesparticlessoundsSun, 29 Jul 2018 20:39:27 GMTsistercrystalMultiple sound for different occasionhttp://answers.unity.com/questions/1518458/multiple-sound-for-different-occasion.html
I am currently new to this software and am looking forward to make a sci fi game. The only thing which is obstructing me is that while flying the plane, I want an engine sound, while thrusters are on, I want a different one and when descending, another one. So how can I make a script which will then enable me to produce different sounds for different events.
P.S. :- Also, if possible, it would be really appreciated that if you can just send a script too.gamesoundscripting beginnersoundsFri, 15 Jun 2018 11:44:17 GMTCuNoistemSound Levels vary between levels with same settings?http://answers.unity.com/questions/1507116/sound-levels-vary-between-levels-with-same-setting.html
I have a 7 level game build, and the same objects (prefabs) all copied and dropped into each of the levels. The same programming is applied to them, and general settings to each level. However some of the audio levels on these prefabs vary hugely between levels. Sometimes they are barely audible, and sometimes a little on the loud side. I can't see any difference between them... can't see this problem online anywhere any one else encountered this??soundsoundssound effectsWed, 16 May 2018 20:29:05 GMTLeewhittSound volume on different colisionshttp://answers.unity.com/questions/1504504/sound-volume-on-different-colisions.html
I have a sound and an object to collide with.
I want the sound to play (but muted) on awake, but to un-mute on collision.
Tbh, I have no idea how to script it. Can someone help, I tried using unity library and coding it myself, but I get serious compiler errors all of the time.collisionsoundscolidermuteThu, 10 May 2018 12:12:18 GMTkardamzaimovPlaying and Pausing multiple audio clipshttp://answers.unity.com/questions/1503230/playing-and-pausing-multiple-audio-clips.html
Hello!
I am pretty new at unity and c# and struggling on how to use two (or more) separate audio clips on my GameObject.
I have a sort of "footsteps on grass" sound that is playing when:
" float orizzontale = Input.GetAxis("Horizontal");" is > or < than 0 and stop when it's 0.
Now footsteps in the grass is working fine: It stops and it comes again ... but when I jump I can't hear sound.
I think the reason is that i put AUDIOSOURCE in pause or stop. How can I pause just a clip and not the whole Audiosource?
void SuoniPorco(float orizzontale) {
if (orizzontale < 0 && !suoni.isPlaying && !porcoInVolo || orizzontale > 0 && !suoni.isPlaying && !porcoInVolo) **//If my player is moving and is not jumping, then ...**
{
suoni.PlayOneShot(cammina); **// Play Sound Clip Until ....**
}
if (Mathf.Abs(orizzontale) < 0.001 || porcoInVolo) **//Player is not moving or he's jumping**
{
suoni.pause(); **//If so ... PAUSE this clip**
}
**// IF player Jumps ... then PLAY a JUMP sound**
if (porcoSalta) {
suoni.PlayOneShot(salto);
porcoSalta = false;
}
}audiosourceaudioclipsoundsMon, 07 May 2018 20:13:43 GMTFeretroHow to start a sound not from it's start ?http://answers.unity.com/questions/1496951/how-to-start-a-sound-not-from-its-start.html
Hello, I don't find anywhere how to do this if anyone has an idea?
How can I start a sound at 1s of it for example?c#audiosoundaudiosourcesoundsSat, 21 Apr 2018 16:50:30 GMTSilverSho0thow to start a song in the middle?http://answers.unity.com/questions/1492605/how-to-start-a-song-in-the-middle.html
I have a few sounds, but the actual sound starts in the middle of the clip. is there a way to start a sound at a certain time in it, preferably by code.soundsoundsclipsWed, 11 Apr 2018 23:34:19 GMTBlazerLazerseperate sliders for music and sound slidershttp://answers.unity.com/questions/1485491/seperate-sliders-for-music-and-sound-sliders.html
Hi,how to setup slider for sound effects? I have music slider and it works across all scenes,but cant figure it out how to do that for sound.I cant find solution anywhere on the internet This are my scripts for music.Any solution? :)
playerprefs
public class PlayerPrefsManager : MonoBehaviour {
const string MASTER_VOLUME_KEY = "music_volume";
const string MASTER_SOUND_KEY = "sound_volume";
public static void SetMasterVolume(float volume)
{
if (volume >= 0f && volume <= 1f)
{
PlayerPrefs.SetFloat(MASTER_VOLUME_KEY, volume);
}
else
{
Debug.LogError("Master volume out or range");
}
}
public static float GetMasterVolume()
{
return PlayerPrefs.GetFloat(MASTER_VOLUME_KEY);
}
public static void SetSoundVolume(float soundVolume)
{
if (soundVolume >= 0f && soundVolume <= 1f)
{
PlayerPrefs.SetFloat(MASTER_SOUND_KEY, soundVolume);
}
else
{
Debug.LogError("Master volume out or range");
}
}
public static float GetSoundVolume()
{
return PlayerPrefs.GetFloat(MASTER_SOUND_KEY);
}
}
music
public class Music: MonoBehaviour
{
private AudioSource Audio;
public AudioClip startClip;
public AudioClip gameClip;
static Music instance = null;
void Start()
{
Audio.volume = PlayerPrefsManager.GetMasterVolume();
if (instance != null && instance != this)
{
Destroy(gameObject);
}
else
{
instance = this; //ako je preuzeta ne ovo ne unistavaj
GameObject.DontDestroyOnLoad(gameObject);//uzima instancu game object i postarace se da ne unisti kad se pokrene
}
}
private void OnEnable() //this method is required to replace OnLevelWasLoaded().
{
SceneManager.sceneLoaded += OnSceneLoaded; // subscribe
}
private void OnDisable() //this method is required to replace OnLevelWasLoaded().
{
SceneManager.sceneLoaded -= OnSceneLoaded; //unsubscribe
}
private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
Audio = GetComponent<AudioSource>();
if (scene.name == "MainMenu") //switched to scene.name since the previous methodology didn't work.
{
if (!Audio.isPlaying || Audio.clip != startClip)
{
Audio.clip = startClip;
Audio.Play();
}
}
if (scene.name == "Levels")
{
if (!Audio.isPlaying || Audio.clip != startClip)
{
Audio.clip = startClip;
Audio.Play();
}
}
if (scene.name == "Level1-Birds" || scene.name == "Level1-Wild" || scene.name == "Level1-Farm" || scene.name == "Level3" || scene.name == "Level3-1" || scene.name == "Level4-1" || scene.name == "Level4-2" || scene.name == "Level4-3")
{
if (!Audio.isPlaying || Audio.clip != gameClip)
{
Audio.clip = gameClip;
Audio.Play();
}
}
}
public void SetMusicVolume(float volume)
{
Audio.volume = volume;
}
}
option controller
public class OptionsController : MonoBehaviour {
public Slider musicSlider;
private Music music;
public LevelManager levelManager;
// Use this for initialization
void Start () {
music = GameObject.FindObjectOfType<Music>();
musicSlider.value = PlayerPrefsManager.GetMasterVolume();
}
// Update is called once per frame
void Update () {
music.SetMusicVolume(musicSlider.value);
}
public void SaveandExit()
{
PlayerPrefsManager.SetMasterVolume(musicSlider.value);
levelManager.LoadScene("MainMenu");
}
//public void SetDefaults()
//{
// volumeSlider.value = 0.8f;
// difficultySlider.value = 2f;
}playerprefssliderinstancemusicsoundsMon, 26 Mar 2018 15:58:39 GMTnickking92Running sounds repeat too often?http://answers.unity.com/questions/1480954/running-sounds-repeat-too-often.html
Obviously the sounds are being called every frame so even if you put a delay in between the different stepping sounds you'll be hearing those sounds 60 times per second whenever you hit the key that moves the character forward. Maybe I'm stupid but how would you prevent that, even if you made a bool true whenever the character is running and then made that trigger a coroutine wouldn't the code keep running every frame. Maybe I'm just confused, anyone care to set my mind straight. :)
StartCoroutine("RunningSounds");
IEnumerator RunningSounds()
{
yield return new WaitForSeconds(0.5f);
walk1.Play();
yield return new WaitForSeconds(0.5f);
walk2.Play();
yield return new WaitForSeconds(0.5f);
}soundsrunningstepThu, 15 Mar 2018 23:48:54 GMTHaugkallManage several sounds with one scriptshttp://answers.unity.com/questions/1474373/manage-several-sounds-with-one-scripts.html
Hey everyone !!
First thank you reading this !! I've open this question beceaus i really need helps
Well, i'm working on a game with a group, i care about sounds and the thing we want to do it's making an only script that offer specific methods wich the goal is macking songs. Like that, my group can use those methods on their script
But about question of optimizations, we want to do this : instead of creatin methods that taking AudioSource and AudioClip in parameters , we want that ALL the AudioSource and AudioClip we need be located on the script carring sound methods !
In this way it avoids to allocate memory by copying in memory parameters of methods, by using directly them into the script source of those methods
BUT !!!! I've tryed again and again and i didn't achieve to make this real , they tried to help me but in vain...
Here is really a way to handle this ? I'm now wondering if it's not possible to do this x) (i've tried creating a new class by using heritage that contained all AudioSource and AudioClip we need, i've tried make method/class statics and i noticed that there was a mess of conflict in Unity with the 'static' key word, i've tried too load clip directly from folders, ....)
So, i have to tell that i've often put the scripts that handle the AudioSource and AudioClip objects 'variaables' into a empty gameobject for allowing the "drag and drop" of AudioSource and AudioClip to the Scripts, but i start to think that we can't do this and that we can only put AudioClip/AudioSource into a script IN the gameobject wich those Audioclip/AudioSource will affect ...
SO ! Thanks for having reading this until here x) , i do not expect answers due to the specificity and nature of that question x) .... But thank you so much if you answer me
Here is the 'main' code in question after removed 'static' key word and befor all the mess of the changes i've try to make it work
( and do not care about the 'french' comments if it disturbs you i'm sorry x) )
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// /!\ ATTENTION CE SCRIPT VA BEAUCOUP CHANGER, NOTTEMMENT LORSQU'ON VA METTRE PLUSIEURS ARME,JE VERRAI AVEC VOUS CAR IL FAUT ADAPTER LE SCRIPT EN FONCTION DES ARMES
public class Sounds : MonoBehaviour
{
private AudioSource AK47;
private AudioClip AK47shootSound;
private AudioClip AK47reloadSound;
#region AK47
#region membres
private float timeSound = 0.001f; // temps du son de tir joué au fur et a mesur que l'on presse le bouton
private float cadence = 0f; // permet de cadencer les tirs de l'AK K7
#endregion membres
#region AK47shoot
public void AK47shoot(AudioSource AK47, AudioClip AK47shootSound,int nmbreDeMunitions = 1, float volume = 0.3f) // int nmbreDeMunitions = 1 et float volume = 0.3f son des membre només, pour les appeler il faut faire Sounds.AK47shoot(AK47, AK47shoot, munitions, volume);
{
if (nmbreDeMunitions != 0) // Si il n'y a plus de munitions, alors le bruit de tir ne se fait plus car on ne sait plus tirer
{
if ((Input.GetButton("Fire1")) && (timeSound >= cadence)) // permet de s'assurer que le boutton est résté appuyé, ainsi que de cadencer les tirs
{
AK47.Stop(); // permet de jouer le son de la prochaine balle qui arrivera
AK47.clip = AK47shootSound; // defini le son qu'emet l'AK47
AK47.volume = volume; // defini le volume de l'AK47
AK47.spatialBlend = 0.8f;
AK47.Play(); // joue le son de l'AK47
timeSound = timeSound + Time.deltaTime; // permet de savoir le temps de son joué
cadence = cadence + 0.100f; // Permet de initialiser la cadence a 1 tir tout les 0,1s, soit la candence réelle d'un AK47 : https://fr.wikipedia.org/wiki/AK-47
}
else if (Input.GetButton("Fire1")) // Permet l'empechement d'une boucle de son infinie
{
timeSound = timeSound + Time.deltaTime;
}
else if (!Input.GetButton("Fire1")) // permet de toujours initialiser ces variable a zero pour pouvoir retirer apres
{
timeSound = 0.001f;
cadence = 0f;
}
}
}
#endregion AK47shoot
#region AK47reload
public void AK47reload(AudioSource AK47, AudioClip AK47reloadSound, float volume = 1f)
{
AK47.Stop();
AK47.clip = AK47reloadSound;
AK47.volume = volume;
AK47.Play();
}
#endregion AK47reload
#endregion AK47
#region Movement
#region FootSteeps
public void FootSteepsSound(AudioSource personnage)
{
if (!personnage.isPlaying) personnage.PlayOneShot(personnage.clip);
}
#endregion FootSteeps
#region jump
public void JumpSound(AudioSource piedPersonnage)
{
if (!piedPersonnage.isPlaying) piedPersonnage.Play();
}
#endregion jump
#endregion Movement
}scripting problemsoundsTue, 27 Feb 2018 22:36:05 GMTGeneralKaiminusHave problems with repeating sounds on target platformhttp://answers.unity.com/questions/1472613/have-problems-with-repeating-sounds-on-target-plat.html
The problem is next. My character is shooting with some rate, and i edited shoot sound to fit great in this tie period. And when i play in editor shooting sounds great. BUT when i build it for android and launch on my phone it is terrible. Sound is not played properly and is getting teared. Seems like in every shot cooldown gets different time and sometimes sound is not player fully. But again in editor it works great. What can be the problem? Someone?soundsFri, 23 Feb 2018 20:53:45 GMTTramplexAudio stutter on simple "sound-keyboard" AR gamehttp://answers.unity.com/questions/1465482/audio-stutter-on-simple-sound-keyboard-ar-game.html
Hi guys
So, I'm trying to build a very simple AR soundboard. I got it to work with an array of sound clips and a switch statement within update that looks for the button name = hit.transform.name; via raycasting.
my question however is that when i play back the sounds on my android device, the sounds stutter. do any of you have an idea of that is going on?soundsWed, 07 Feb 2018 14:35:39 GMTeyeofraScroll rect sound problemhttp://answers.unity.com/questions/1463722/scroll-rect-sound-problem.html
Hello,
I created horizontal scroll panel with list of buttons,the problem i cant figure out is when i click on button,it makes sound but when i scroll left or right continues playing on the next items.What i want is sound to stop when i scroll to the next.I guess that could be changed with on OnValueChanged in scroll rect script,but i have no idea how to do it.Any solution?audiosourcebuttonsscrollpanelsoundsSat, 03 Feb 2018 15:01:54 GMTnickking92Is there any way to play soundfonts with xml or json files?http://answers.unity.com/questions/1463324/is-there-any-way-to-play-soundfonts-wuth-xml-or-js.html
Is there any way to play soundfonts with xml or json files, using C# or .NET librariessoundsFri, 02 Feb 2018 13:26:56 GMTMrNopi