Is there any way to switch motor states during user control?

So I want to be able to toggle motors from true to false and false to true is there a way to do this or do I need to deal with not being able to switch direction? The current code I had but didn’t work last time I tried to get it to work.
void DriveDirection(){
if(drivestate){
LeftDrive1 = true;
LeftDrive2 = true;
LeftDrive3 = true;
RightDrive1 = false;
RightDrive2 = false;
RightDrive3 = false;
drivestate = false;
}else{
LeftDrive1 = false;
LeftDrive2 = false;
LeftDrive3 = false;
RightDrive1 = true;
RightDrive2 = true;
RightDrive3 = true;
drivestate = true;
}
}
then in user control this callback:
Controller1.ButtonL2.pressed(DriveDirection);

I… am kinda lost on what you are talking about, but this works as a toggle

void invert(){
LeftDrive1 = !(LeftDrive1);
}

Just set the velocity to negative, in python motor.set_velocity(-whatever,percent or rpm)

1 Like

You can read through this : Reversing Drive Code | Rolling Robots