- Home /
Question by
valtterim · May 04, 2013 at 01:55 PM ·
javascriptsoundonmouseenter
Play sound on mouse enter
Im really new to programming in unity javascript.
So I want that when I look at a object it makes a sound, and when I take the mouse away from it, it makes no sound.
I have a script made which does what I want but just the opposet, so could someone help me?
function OnMouseEnter() {
audio.Stop();
}
function OnMouseExit() {
audio.Play();
}
Comment
Answer by Nercoe · May 04, 2013 at 02:06 PM
You have the functions muddled up, no biggie. Think about it logically "OnMouseEnter" means when the mouse enters the destination. You need to put your audio.Play in here and vice versa for the other.
function OnMouseEnter() {
audio.Play();
}
function OnMouseExit() {
audio.Stop();
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I want my trigger sound only to play once! 0 Answers
Delay Problem, coule be 'OnMouseEnter'? 0 Answers
How to make the trigger work only once. (SOUND) 1 Answer
Java Script: Clock script help. 1 Answer