How can I use switches to activate a walk but turn it off once it collides with something

In my PvZ game, I am trying to work a basic zombie and I’m not sure how to make him walk until he collides with a plant. I’ve tried experimenting with it but my efforts were thwarted by one thing…THE OFF SWITCH

You can use a Raycast (Zombie raycasts Plant) if it hits a plant - turn off the movement switch.
If it misses, turns on the switch.