I’m simulating an electromagnet by using two line forces to pull the two objects together, each with flipped attachments of the other. One is the magnet force, the other is the reaction force. I want to use the InverseSquareLaw property because it’s appropriate for the application, but I’m having trouble.
The issue is that whenever the parts get too close, the force exponentially increases, as it should, but the force becomes so much that it’s bugging out my system. If I just lower the magnitude of the lineforce, I won’t get the power I want to get.
My suggestion is to add a MaxForce property to lineforces that caps effective force. Otherwise, I think I’ll have to check the distance, and if it’s too close, switch to constant force. I don’t really want to do that many magnitude checks.
I don’t think magnitude checks are particularly expensive, but I think scripts not running at the same rate as physics is a potential issue.
Another temporary fix could be to use the Touched event and weld the object to the magnet.