Question by
tonyxdon93 · May 07, 2018 at 06:42 PM ·
collisionaudioaudiosource
How can an gameobject make a sound when touching the player?
basically when the player touches the object I want the audio source for that object to play.
Comment
Answer by Jason246111 · May 07, 2018 at 09:19 PM
@tonyxdon93 Here's a simple script for colliding to trigger a sound.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Item : MonoBehaviour
{
public AudioSource CollectSound;
void OnTriggerEnter(Collider other)
{
CollectSound.Play();
}
}
Your answer
Follow this Question
Related Questions
Collision to change Pitch 0 Answers
Wanting audio to pause on trigger enter 1 Answer
How to make audio play at once. 1 Answer
audio is not playing during IEnumerator 1 Answer
Cracking at end of audio? 0 Answers