unsetting OPTINT in getopts

i am calling a function multiple time which uses getopts to parse function arguments.
WHile running, i am getting a bad shift error. i read somewhere that we have to reset the OPTIND variable after each getopts call. how do we do it?
using unset OPTIND doesn't help:(

If you want to reset it, you don't want to unset it:

OPTIND=1

when ever shell invokes OPTIND is initialized to 1
since you are calling function many times in same shell you are getting that error
so as cfajohnson suggested set OPTIND to in at the starting of function