J
J
Jourloy2017-07-04 01:49:44
Game development
Jourloy, 2017-07-04 01:49:44

How to change the movement sound depending on the surface in Unity?

I am working on a project in Unity. I have all the necessary sounds for moving on grass, asphalt, etc., but I don't understand how to make the character change the movement sound if he moves from grass to sand, for example.

Look in
More details if possible

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Pogrebnyak, 2017-07-04
@Jourloy

Add the character to the OnTriggerEnter(Collider col) event, where it will be:

switch (col.gameObject.tag)
{
case "Sand":
GetComponent<AudioSource>.audioClip = sandStepAudio;
case "Ground:
...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question