So did I do it right?

My boyfriend and I had unprotected sex the day before my period was supposed to start, dec 12 we had sex and dec 13 my period was about to start. Hours past (the same day) I took plan b Ik it will make my period late. I’m one day late and have cramps and feel like my periods is about to start. Was I supposed to take it hours after the unprotected sex or I was supposed to wait a day ( i took the pill like I’ll say 1-3 hours after sex) he didn’t cum in me but ik precum could cause pregnancy.