We use a distance sensor for our kicker with autofire. If it detects a triball, it will fire it. However, before it fires and detects it again, it makes sure to stop at the same position it started in and then after it comes to a complete stop, will it actually fire again. Kinda slow and ineffective and we want a better skills score.
So the fix is simple, just tell the code to not come to a stop and if it detects a triball while it’s firming, just keep firing. Although, im not sure how to go on about doing that.
while (shootCounter < 44) {
if (Distance.objectDistance(mm) < 100 && Distance.objectDistance(mm) > 20) {
shoot = true;
Shoot();
Brain.Screen.setCursor(2, 2);
Brain.Screen.print(shootCounter);
}
}
shoot = false;
And this is the function Shoot:
void Shoot()
{
if (shoot==true) {
Shooter.setVelocity(100, percent);
Shooter.spinTo(-1, rev, true);
shootCounter = shootCounter+1;
Shooter.setPosition(Shooter.position(rev)+1, rev);
if (!Controller1.ButtonR1.pressing()) {Shooter.stop(); shoot = false;}
}
}
I’ve tried making it work by placing the “if distance between is correct to fire a triball” if statement inside the definition of Shoot but I don’t know how I would say to not stop. Just need help to think out the logic. Kinda hit a wall with this one.