▲ 3 r/Algodoo
Hello. I have an object which I want to change color when another object (kart) touches it. However I only want the object to change color onces per kart. My solution to this was to add a _colors variable (an empty array) to the object and a _colorid variable (an int) to the karts. Then I would check if _colorid is in _colors and execute some code if it's not. Here's the full script (in onCollide of the object)
(e)=>{
exists = false;
for(e.this._colors.size, (i)=>{
e.this._colors(i) == e.other._colorid ? {
exists = true
} : {}
});
exists == false ? {
e.this._colors = e.this._colors ++ [e.other._colorid];
e.this.color = e.other.color
} : {}
}
This doesn't work but I can't figure out why.
u/Alive-Trouble3628 — 13 days ago