Hello,

I’m new here. I am trying to control an object oriented project with a midi controller.

After doing my oop sketch (thanks to the coding train), I thought I should use the midiBus library. But I can’t figure how to add the void controllerChange in it. I tried to put it in the object class but the println won’t work so this must not be the proper thing to do. Also, I was trying to change floats and not vectors and maybe this is not even possible.

Sorry if this might seem an obvious topic.

```
class Vehicle {
PVector position;
PVector velocity;
PVector acceleration;
float r;
float sw;
float sline;
float slinea;
float maxforce; // Maximum steering force
float maxspeed; // Maximum speed
float bigger;
// Constructor initialize all values
Vehicle(float x, float y, float contour, float line, float linea) {
position = new PVector(x, y);
r = 4;
sw = contour;
sline = line;
slinea= linea;
maxspeed = 4;
maxforce = 0.1;
acceleration = new PVector(0, 0);
velocity = new PVector(0, 0);
}
void controllerChange( int number, int value) {
println(number);
if(number==13){
bigger= map(value,0,127,0,250);
println("gros:"+grooos);
}
}
void applyForce(PVector force) {
// We could add mass here if we want A = F / M
acceleration.add(force);
}
void applyBehaviors(ArrayList<Vehicle> vehicles) {
PVector separateForce = separate(vehicles);
PVector seekForce = seek(new PVector(mouseX,mouseY));
separateForce.mult(1.0);
seekForce.mult(0.5);
applyForce(separateForce);
applyForce(seekForce);
}
PVector seek(PVector target) {
PVector desired = PVector.sub(target,position);
desired.normalize();
desired.mult(maxspeed);
PVector steer = PVector.sub(desired,velocity);
steer.limit(maxforce);
return steer;
}
PVector separate (ArrayList<Vehicle> vehicles) {
float desiredseparation = r*4;
PVector sum = new PVector();
int count = 0;
for (Vehicle other : vehicles) {
float d = PVector.dist(position, other.position);
// If the distance is greater than 0 and less than an arbitrary amount (0 when you are yourself)
if ((d > 0) && (d < desiredseparation)) {
// Calculate vector pointing away from neighbor
PVector diff = PVector.sub(position, other.position);
diff.normalize();
diff.div(d);
sum.add(diff);
count++; // Keep track of how many
}
}
// Average -- divide by how many
if (count > 0) {
sum.div(count);
sum.normalize();
sum.mult(maxspeed);
sum.sub(velocity);
sum.limit(maxforce);
}
return sum;
}
// Method to update position
void update() {
velocity.add(acceleration);
velocity.limit(maxspeed);
position.add(velocity);
acceleration.mult(0);
r= r+bigger;
}
void display() {
//strokeWeight(sw);
//stroke(sline,slinea);
pushMatrix();
translate(position.x, position.y);
ellipse(0, 0, r, r);
popMatrix();
}
}
```

If you have any idea, that would be great,

Thanks!