Given that the child is only 2 it will mean that you have to petition the court to be asked to become the legal father of the child. That should not be a big problem if the mother agrees to that. Once you have the ruling you can get an extension of stay based on your child, if you can show an income of 40,000 THB a month OR 400,000 in an account in Thailand in your name.
At this moment you will not qualify for an extension of stay, as you are not the legal father. You might try a 60 day extension of stay based on your child if you are mentioned as the father on the birth certificate. (Marrying the mother would automatically make you the legal father of the child).
If that doesn’t work out or is not long enough, you will have to leave the country to get a visa. Till you have a court ruling, you can get a non-O visa from a neighbouring country if you are mentioned on the birth certificate as the father.