Castle Crasher lesson 3 - Gen 2 Distance sensor code not functioning

I am trying to help my students figure out the Castle Crashers lesson 3 distance sensor code. Code should make robot go in a circle until it finds a cube, then push it off platform and return to middle. Should find 4 different cubes in this way, however, the robot ends up just finding the first cube, then drives forward and backwards 4 times rather than turn to find the next cube. Here is a snippet of code of the first two times it finds a cube. I tried having it in a repeat 4 times loop, too, but that also resulted in the same outcome. Any help or example code would be appreciated.

Solved my own problem! For those of you struggling with the same issue - making line 3 ‘wait until Distance7 found an object? AND Distance7 object distance in inches < 18:’ worked.

Also - Flipping the distance sensor upside down on the base build will stop the distance sensor from sometimes seeing the ground as an object.

1 Like

I was just coming here with the same issue! Glad you were able to figure it out! Thank you for sharing!