Getting targetposition for prismatic constraint from vector3 value

I am trying to get a prismatic constraint to extend to the correct target position to where it stops at the Y value of another part.

I tried accomplishing this by subtracting the y position of the part with the prismatic constraint and the y position of the part at the target y position. However this usually won’t work, as it’ll usually pass the intended y position.

How do I accomplish this?

1 Like

I don’t understand what you are asking, is there any way you can explain this in more detail? Possibly, including an image of intended behavior?

1 Like

I simply want a prismatic constraint to raise a part attached to it to a certain Y position. I need to find a way to find out what TargetPosition should be set to in order for the prismatic constraint to raise the part to the specified Y position.

1 Like

What should the Y point be based off of? It sounds like you should use object space of the relative part to determine what the Y should be.

Just set the second attachment of the prismatic constraint’s position to Vector3.new(0, Attachment1.Parent.Size.Y / 2, 0).

That is, if I understood what you were trying to say.

Fixed it, I was getting the TargetPosition by subtracting the target floor position - the elevator position when I should’ve just done the floor position the prismatic constraint was on - the target floor position.

(this is an elevator)

1 Like