I am working on a physics driven pressable button, but I cannot seem to tackle the minimum and maximum limits.
The idea is that the box collider is a trigger and the button (cylinder, mesh collider) is a rigidbody with configurable joint, locked and limited on a single axis. I am using configurable joint, as that's the only one that supports basic, linear restrictions.
I have set up the configurable joint to restrict motion on a single axis, but the joint only allows single dimensional limit, that is applied to both directions. Screen capture of relevant configuration:
Basically, the opened
Linear Limit section is the last property that has been changed for the joint - anything else are defaults and irrelevant (at least I haven't found my solution in the properties below, mostly angular stuff).
The limit of
0.2 units work, and the button can be pressed - it only gets pressed until those
0.2 units and thats the expected behaviour.
The unexpected is that sometimes the angle at which I hit the button, adds force to the button outwards from the box, and it moves
0.2 away from it, ending up like this:
Obviously, the specified limit of
0.2 units constrain the movement in both directions from the anchor, actually resulting in the range of
0.2 (relative to anchor).
How, and is it even possible, to restrict the movement only in a single direction relative to anchor?