Answer the question
In order to leave comments, you need to log in
How to make the sound infinite when pressed?
I wrote a script so that when I click on a character it would play a sound but only 1 time
but I need it to play a sound endlessly until I click on it again and it turns off
Here is the Script itself:
using UnityEngine;
public class Sounds : MonoBehavior
{
public AudioClip din;
AudioSource audio;
void Start()
{
audio = GetComponent();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse1)) //set any button
here audio.PlayOneShot(din);
}
}
If someone fumbles in this, help ;)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question