34
edits
m (→Unity: more screenshots. (ok just one)) |
m (→Example: Make an object jump on clapping: formatting) |
||
Line 94: | Line 94: | ||
a) Install an additional library for sound. Click on ''Tools'' – ''Add Tools'' – Choose ''Libraries'' – Search for Minim and install it. <br> | a) Install an additional library for sound. Click on ''Tools'' – ''Add Tools'' – Choose ''Libraries'' – Search for Minim and install it. <br> | ||
b) To your imported Libraries add <br> | b) To your imported Libraries add <br> | ||
< | <source lang="javascript"> | ||
import ddf.minim.*; | import ddf.minim.*; | ||
</ | </source> | ||
c) Add Audio variables to your script. This script will also draw a circle depending on the audio volume. <br> | |||
c) Add Audio variables to your script. This script will also draw a circle depending on the audio volume. <br>< | <source lang="javascript"> | ||
float x;<br> | float x;<br> | ||
float y;<br> | float y;<br> | ||
Minim minim;<br> | Minim minim;<br> | ||
AudioInput input;</ | AudioInput input; | ||
d) In the Setup() function add the values for the circle and create the audiotoolkit <br>< | </source> <br> | ||
d) In the Setup() function add the values for the circle and create the audiotoolkit <br> | |||
<source lang="javascript"> | |||
size (320, 240);<br> | size (320, 240);<br> | ||
smooth();<br> | smooth();<br> | ||
Line 113: | Line 115: | ||
minim = new Minim (this);<br> | minim = new Minim (this);<br> | ||
input = minim.getLineIn (Minim.STEREO, 512);<br> | input = minim.getLineIn (Minim.STEREO, 512);<br> | ||
background (0);</ | background (0); | ||
e) The draw() function will be the container of the circle’s size. It will only send the values to Unity if the circle is big enough. <br>< | </source> <br> | ||
e) The draw() function will be the container of the circle’s size. It will only send the values to Unity if the circle is big enough. <br> | |||
<source lang="javascript"> | |||
void draw () {<br> | void draw () {<br> | ||
int i =0;<br> | int i =0;<br> | ||
Line 122: | Line 126: | ||
myMessage.add(dim);<br> | myMessage.add(dim);<br> | ||
myMessage.add(true);<br> | myMessage.add(true);<br> | ||
oscP5.send(myMessage, myRemoteLocation);}</ | oscP5.send(myMessage, myRemoteLocation);} | ||
</source> <br> | |||
f) When you are ready, press Play. <br> <br> | f) When you are ready, press Play. <br> <br> | ||
'''2. In Unity:''' <br> | '''2. In Unity:''' <br> | ||
a) Create an object in Unity. Drag this object onto the gameReceiver of your Osc Receiver Script. This object is now the gameReceiver and will behave as you define in the Osc Receiver script. <br> | a) Create an object in Unity. Drag this object onto the gameReceiver of your Osc Receiver Script. This object is now the gameReceiver and will behave as you define in the Osc Receiver script. <br> | ||
b) Open up the Osc Receiver Script. Define a new private variable.<br>< | b) Open up the Osc Receiver Script. Define a new private variable. <br><br><source lang="javascript"> | ||
private var moveSpeed : int = 0; </ | private var moveSpeed : int = 0; | ||
c) Create a new public function.<br>< | </source> <br> | ||
public function MoveObject(msgValue) : void | c) Create a new public function.<br> | ||
{ | <source lang="javascript"> | ||
moveSpeed = msgValue; | public function MoveObject(msgValue) : void | ||
}</ | { | ||
d) In the Update() function add <br>< | moveSpeed = msgValue; | ||
} | |||
</source> <br> | |||
d) In the Update() function add <br> | |||
<source lang="javascript"> | |||
var go = GameObject.Find(gameReceiver);<br> | var go = GameObject.Find(gameReceiver);<br> | ||
go.transform.Translate(0, moveSpeed, 0); </ | go.transform.Translate(0, moveSpeed, 0); | ||
e) In the AllMessageHandler() function add <br>< | </source> <br> | ||
switch (msgAddress){ | e) In the AllMessageHandler() function add <br> | ||
default: | <source lang="javascript"> | ||
MoveObject(msgValue); | switch (msgAddress){ | ||
break;}</ | default: | ||
MoveObject(msgValue); | |||
break;} | |||
</source> <br> | |||
f) When you are ready, press Play. | f) When you are ready, press Play. | ||
edits