- Home /
This question was
closed May 20, 2018 at 08:55 PM by
Catdogfatness.
Question by
Catdogfatness · May 20, 2018 at 03:05 AM ·
2daudiocollision2daudio.playoneshot
PlayOneShot not playing sound
A sound is supposed to play when the object is hit, but the sound is not playing. I already have an audio listener component attached to the camera.
What am I doing wrong?
My code:
AudioSource sound;
void Start ()
{
sound = GetComponent<AudioSource>();
}
void OnCollisionEnter2D(Collision2D col)
{
sound.PlayOneShot(sound.clip, 1.0F);
}
The inspector for the object:
collisions-problem.png
(58.0 kB)
Comment
Your collision might not work. Call debug OnCollisionEnter2D before ask this question
Answer by Captain_Pineapple · May 20, 2018 at 06:47 PM
Put the spatial blend slider to the far right, that fixed it for me.
Follow this Question
Related Questions
2D Animation does not start 1 Answer
How to make a little wiggle room for the collision? 1 Answer
Prevent objects from pushing eachother on collide 1 Answer
Memory Profile shows increased Audio size 1 Answer
audio.Play Help :S 2 Answers