Let’s say I have two objects (b1 and b2) with different values of variables. When they are interacting, b2 has probability (let’s say 30%) to copying b1’s values. Then, after a given amount of time b2 will change its value again to default. Anyone can help me make this code works?
int p_i = int (random(0, 100));
if (b1.state==-1 && b2.state==0 && p_i < 30) {
b2.state=b1.state;
b2.cR=b1.cR;
b2.cG=b1.cG;
b2.cB=b1.cB;
int TimeInfected = millis() - savedTime;
//println(TimeInfected);
if (TimeInfected > incubationTime) {
b2.state=1;
b2.cR=0;
b2.cG=255;
b2.cB=0;
print(b2.cR);
savedTime = millis();
}
}