Hi there Ethan,
What type of case? Criminal or civil? What is the matter you are referring to?
In a civil case, depending on the circumstances, courts can direct each party to pay their own costs. Or if you reach a settlement, that can be part of the settlement terms.