Constraint Help

I need a constraint like a spring, but not as broken. Basically i need 1 part to be inside another, and if the main part goes inside a solid wall, then the other part will actually obey physics, and stay outside the wall. I tried this with a spring but they just glitch out or moves and wobbles too much.

3 Likes

Can you send a video? Is the main part uncollidable? Also maybe some of the constraint settings are bad because springs don’t usually glitch out unless there are ridiculously high forces or the part is small.

1 Like

My internet is not that good so it would take a while to upload a video. I can explain whats happening and parameters.
The parts are both 1x1x1, 1 part is anchored, the other is not. the anchored part has no collision. The anchored part is a cube, the unanchored one is a sphere. Ive tried using: spring constrain, and ball constraint. The ball constraint gave better results, because it stayed in place, but still had some free movement. Only issue is that it would faze through walls with the anchored part. i tested with the spring a lot, for almost an hour i belive in total. Couldnt get anythign right.

Try making the spring constraint have a higher max length and decreasing the force it has. Also how thick is the wall?

Well i need the parts to be inside eachother, and a spring cant do that. Its minumum resting length is 0.1

You can offset the attachment the spring is connected to :slight_smile:

Alright well i cant find out good paremeters for the spring still, im tired of testing over and over again, also the wall is of variable size because this needs to apply to all kinds of surfaces

Well if the wall is too thin it will break. Also set the spring to like the least springy it can be and slowly make it stiffer until you get to your desired effect.

I tried that, could you maybe help with finding the best paremeters?

Cant at the moment but if you send the files I can try when I get home.

Its just 2 parts that are both 1x1x1 in size, 1 is anchored one isint, anchored part is a cubve and has no collision, uncachored has collision and is a ball
image

1 Like

heresa the explorer
image


This is what happens s soon as it starts staying in the middle and i move it around

What’s the properties of the spring constraints?

Edit: like what do you have them set as

sorry just saw this
i dont remeber and i set them in-game, so it didnt save when i ended playtest

You need to add a PrismaticConstraint + a SpringConstraint to keep the spring motion in line, otherwise the SpringConstraint acts like a real life spring with no solid attaching points.
Your Attachments don’t keep the spring pointing in one direction.

To keep the Parts both CanCollide true you’ll have to add both to a CollisionGroup which doesn’t collide with itself but collides with items in the Default CollisionGroup.

I dont want it in line though
char limit

Heres an example
Example
The yellow ball is the part that shouldnt faze through, the grey part is the anchored part that should faze through, and the tan line is a wall.

Also keep in mind i dont want to use a prismatic constraint to keep it in line.

Do you want it to move in every direction?

What’s the reason for doing this? Could you use a Shapecast to find if the ball Part is within 1 stud of a surface and code it using that?

Im making a VR game and i dont want ur arms to be so strong it pushed ur body away if u hit a wall, So my idea is to move the grey anchored part to your controller position (i have that working) and then have the yellow part be the IK target for you in game hands, so you dont push your whole body away when moving your arms, and its more realisitc because you ant put ur hands through the walls