Hallo. I am trying to create a piano where if the player clicks on it he can roll the mouse through the keys, playing all of the notes the mouse passes through. Now, I got the piano working, but I can’t get the mouse to activate all keys it rolls onto. After hours of attempts, I humbly ask for your help. An yes, I am a noob in this.
Here is the code:
var note : AudioClip;
var over = 0;
var down = 0;
var mdown : boolean;
mdown = false;
function OnMouseDown () {mdown = true;}
function OnMouseUp () {mdown = false;}
if (mdown == false) {return;}
function OnMouseOver () {
if (down==0)
{
// Perform thingy.
audio.PlayOneShot (note);
transform.Rotate(1.8, 0, 0, Space.Self);
down = 1;
yield WaitForSeconds(0.2);
transform.Rotate(-1.8, 0, 0, Space.Self);
down = 0;}
}
huttch, would that not only cause it to play once clicked upon? And will this not cause the key to press even if the player misses it?
Ohm perfect! Thank you. I did not study your code correctly
I wonder why I didn’t think of that… Anyway, thanks.
it should work, depends on how your piano's setup, give it a try, if not then ill have a look at your project if you want and help
– huttchyour welcome
– huttch