Hmmm…seems like I lost the C# script?
APK crashed on start up in Oculus
should be fixed now!
That’s great and it worked!
Do you mean that sending a duration of “-1” will only allow the event to be sent once?
The problem I had was that, when my hand stayed on an object, it kept sending the score event every frame and Csound almost exploded, unless I touch the object as fast as one frame. I want to send an event once by touching a sphere without exiting, like the PlayOneShot function, or pressing a keyboard that only triggers a midi note once no matter when I release the keyboard. And when I retouch it, it will send the event once again.
It sounds like your example did send only once. I was using OnTriggerEnter instead of OnCollsionEnter. Is that the reason why it went wrong? It is interesting that you were not using any bool variables.
Sorry that I am kind of confused
Oh or is it because when Csound is not initialized, the update function will exit?
For example, I have this waterdrip instrument that will have a random frequency every time I hit play in Cabbage which sends a score event.
Would it be possible to touch an object in Unity and achieve the same result? Every time I touch a sphere, it plays a random waterdrip. I just tried the Collision script but it doesn’t make any sound.
The issue here OnCollisionEnter is that it starts instr 1 for two seconds, otherwise it should be fine! Use a duration of -1 to keep an instr active indefinitely.
A negative instr number is needed to stop the instr. There you are starting again instr 1 OnCollisionExit, with indefinite duration.
Try:
i-1 0 -1
This has no effect on the collisions, so they will call Csound SendScoreEvent also if CsoundUnity is not inizialized. Put the check in both the OnCollision functions, before sending the score, to send it only if Csound is initialized.
Also another thing to notice is that if you need more precision in collisions you should use 2 rigidbodies, one on the collision area and another on the object you are moving to collide with it.
I just noticed that you are not sending the score correctly in your OnCollision functions.
Try with:
var score = $"i1 0 -1"; // or $"i-1 0 -1 to stop -> you can also use pfields
csound.SendScoreEvent(score); // instead of "score",
// in your screenshot Csound is receiving "score", and it's not a valid score command :)
Also, be sure to comment the score in the csd, in your example you have:
i1 0 2
which will start the instr 1 for 2 seconds.
Hi!
Sorry for the late reply as I just got out of my finals week!
I had the “i1 0 -1” worked once last week but it was playing with the same glitchy issue. I am gonna try $“i1 0 -1” and comment the score out today and let you know soon!
Happy holidays!