You should definitely ground yourself until you have been thoroughly checked out by a doctor, and until the findings have been discussed with an AME, preferably the one who issued your current pilot medical certificate.
I agree with gingernut that it does not sound as if it's cardiac; anxiety with or without hyperventilation seem likely to me. But even those can be incapacitating in the pressured environment of flight.
If I'm brutally honest, it was highly irresponsible and bad airmanship to carry on to a different destination when you had the opportunity to land more or less immediately. Just think, what if it HAD been cardiac ? ?