I’m trying to set up a linear constraint such that a static mesh can only move so much in a given direction. Think of it like a drawer. When the drawer is closed, it can’t move any more inwards. However it can move outwards by a certain amount. To implement this, I am using a static mesh component that is constrained via a physics constraint component. I set the Linear Limits to be limited on the Z-axis. (My drawer opens vertically in this case)
However it seems like the linear limit is always taken from the center of the physics constraint. See here:
The vertical grey box is the drawer. It should only be able to move upwards. The red box on the bottom shows the line that I don’t want to drawer to cross. The little grey line that I am moving around is the constraint. You can see that when I press play, the piston drops down. I don’t want it to do that. I want to define it so that the drawer can only move 50 units upwards from the start of the constraint. What’s happening now is that it can move 25 units upwards and 25 units downwards from the constraint.
In a perfect world I would put the physics constraint at the base of the drawer, tell it that it can move 50 units upwards, and be done with it. The constraint limits seem symmetrical, and that’s making it hard to do this.
Hi, that’s a problem I’m facing too : how to set up a drawer in a dresser if we can’t define the + and - limits of the physical move ?
Have you find a solution since you asked ?
Ya absolutely. Well for now I had to “simulate” the physics with adding a fake inertia using the physical velocity of the hand controller and setting manually the movement limitation. I thinks this is the best way for now.
Offset the drawer so it’s starting point is the center point of the whole travel. You can close the drawer at begin play if you want it to start closed, it just needs to be centered at the construction time.
I did try that at some point, but I didn’t like how the view from the editor had all the drawers open. The bigger issue though was that if I put stuff in the drawers, they would fly everywhere when the begin play would close the drawers. It just became too messy to ensure proper placement of everything.
Ya you probably have to spawn the elements in the drawer at begin play too (or after a short delay). Or set the collisions at this moment or something.
A bit messy
My example Blueprint (UE4.26): [Constraint_Drawer_BP][2]
Use the “Set Constraint Reference Frame” node to move the center of the linear limit. Let’s say in the physics constraint Component1 is your drawer and Component2 is your furniture, then you need to set Frame2 in the “Set Constraint Reference Frame”.