5 hours trying to solve a simple problem, 1 click to fix it. Not sure who needs to hear this but figured I would contribute. I’m total noob so maybe I’m missing something very basic here but solved a problem and figured others might have encountered same.
Two pinball flippers, code works perfect for 1, the other, flipping in the wrong direction.
Because limits on hinge joint can’t be set with a negative max angle that is a larger number than min.
which to me makes no sense because you should always be able to talk about negative rotations?
so even though I had it set in my code, hinge joint component was changing values in limit to same number.
(took me a while to figure that out, watching the inspector component during play time in prefab edit mode is my new first move now to problem solving).
Example Left flipper limit set to 0 min, 40 max. wrong direction, flips down. Limt set to min 0, max -40. Get’s set on play to -40,-40. because negative 40 is less than 0. set min to -45 and max to 0. it rotates down and flips up to 0. etc. and every other crazy glitch you can imagine trying to fix this with code.
Right flipper works perfect 0 to 40.
So i go back to that code for left flipper.
Try flipping the button actions, and burning an hour on work arounds that don’t work etc.
Then it occurs to me it’s upside down.
maybe flip the joint vectors (even though, I don’t really understand why you would have to. )
change the vector on the connected body axis to -1 from 1. and it worked setting limits 0 to 40.
And I’m like just punching myself in the face for not thinking of that sooner.
When dealing with rotations, you should be able to set it to go from a “higher” number to a lower number. Most objects are probably transformed to 0 degrees on import but you can only turn them clockwise.
Doesn’t make sense to me. But hope that helps. Unless there is a better right way to do this.