- Home /
About sound distortion
Hi! I added walking sound effect to my character and in play mode, the sound is distorted when my character is walking. Does anybody know how to fix it? I have already turned Doppler Factor and Doppler Level to 0 but it didnt work.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class movingcharacterscript : MonoBehaviour
{
public float speed = 0f;
public float rotspeed=80;
public float rot = 0f;
Vector3 movDir = Vector3.zero;
float gravity = 20.0f;
CharacterController controller;
Animator anim;
AudioSource m_AudioSource;
bool AnimPa;
public AudioClip impact;
// Start is called before the first frame update
void Start()
{
m_AudioSource = GetComponent<AudioSource>();
controller = GetComponent<CharacterController>();
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.W))
{
anim.SetBool("AnimPa",true);
movDir = new Vector3(0, 0, 1);
movDir *= speed;
movDir = transform.TransformDirection(movDir);
m_AudioSource.PlayOneShot(impact, 0.5f);
}
else
{
anim.SetBool("AnimPa",false);
movDir = new Vector3(0, 0, 0);
m_AudioSource.Stop();
}
rot += Input.GetAxis("Horizontal") * rotspeed * Time.deltaTime;
transform.eulerAngles = new Vector3(0, rot, 0);
movDir.y -= gravity * Time.deltaTime;
}
}
@ernest326648 I tried use playoneshot but this time no sound at all.
Hello Issac1235, Hard to tell from your description, did you check the following :
The Audio Source playing your walking sound is on the same object as your Audio Listener ?
The Audio Source "$$anonymous$$ch" is set to 1 ?
The Audio Source output is not set to an Audio$$anonymous$$ixer (or that Audio$$anonymous$$ixer doesn't apply any effect) or you set "Bypass Effects" & "Bypass Listener Effect" to true on your audio source ?
There are still a lot of possibilities but those must be the more common ... if you can post a screen or your audio listener & your triggering sound code we might be able to understand what's happening with you
Hi $$anonymous$$eishin, I attached my code. Could you please help me see what went wrong?
Your answer
Follow this Question
Related Questions
One Slider Control More Than One Sound 1 Answer
Can't play multiple sounds at once 2 Answers
Sound effect issues 1 Answer