What is the main source of yaw stability? I am creating a flight simulator and I need to implement lateral and longitudinal stability.
Roll stability is now working because I am computing the lift of each wing independently.
But yaw stability is confusing to me.

What is the main source of yaw stability : is it the weathervaning effect of the tail or is it the sweep angle of the wing ? Which one is the more responsible of stability ?

When I implement weathervaning effect by applying the wind at a certain point of the tail, the problem is that the oscillation will continue and the plane will always overshoot as he is not losing any of its angular velocity. So it will never align into the wind but will keep overshooting from negative to positive angle.

So my other question is : in real life, what does prevent the plane to overshoot wind direction?
When I just apply some scaled-angular drag value to the plane, it helps to dampen the oscillations, but the plane is wayyy to slow to align into the wind and thats just aweful to controll and not realistic at all. So I guess angular drag is not the answer why oscillations stops in real life. There must be another force depending on wind speed or I don't know...

And longitudinal stability is also confusing to me.
I know that it depends on the position of CG, CL and the downforce generated by the tail horizontal stabilizer.
But what about the weathervaning effect ?? Isn't it the main force that explains why the plane align into the wind on its pitch axis ?

As you can see I am a bit confused. I already looked many websites and I mainly understood how stability and flight dynamics work, but as I am working on a simulation, I need some equations to implement, and some concrete values to understand which forces are bigger than others.

Thank you !
Wing sweep does affect yaw stability, but all planes with a vertical tail will "weathervane" into the wind.  It seems you are on the right track considering angular drag as a mechanism of stability, angular lift works even better.  A vertical stabilizer can act as a vertical wing.  Symmetrically, it can generate lift against either deflection.

Secondly, the "overshoot" is a real concern in design, but will be a function of weight as well as "angular drag". Much harder to stop a piano on ice compared to a light cardboard box.  A tail will typically be light, pivoting around the center of gravity.  Ample tail area will make it easier to control.

Finally, as far as "damping" is concerned, one must realize the "viscosity" of air will resist motion as well.  Once a force is removed, drag will help it slow to a stop, so the opposite "correcting force" need not be as large.