Locking attachment to 2D

Hello!

I’m making a 2D game in which I need to use attachments for various reasons like constraints, etc. I have an issue that causes attachments to move overtime as small inaccuracies cause their parent to exit the 2D plane by small amounts.

attachment.WorldPosition = Vector3.new(attachment.WorldPosition.X, attachment.WorldPosition.Y, 0)

I’m trying to figure out how to lock the attachment while still keeping the local position the same even if the parent exits the 2D plane. Could anybody help?

Thanks!

1 Like

Give more context of what you ACTUALLY want to achieve and why you want to keep the attachment on the 2D plane and why not something else.

Make a proper post first: https://xyproblem.info/

1 Like

Hi. I hope this made it a bit more obvious why I need it to be locked but I can see why you are refering to the XY problem. More specifically I need to connect a custom rope made with Hinges while still allowing certain rotations which can cause the attachements to exit the plane (if the local position isn’t ZERO).

1 Like

Ok yeah that explains it more, you can just use one of roblox’s features called the PlaneConstraint for this.
I thought you were refering to a random attachment just floating in the sky, not much to go off from there.

1 Like

I don’t want the attachment getting offset in case for some reason the object exits the plane. It might never happen but I don’t want taking the chance of this happening.

1 Like

Yeah like I said just use PlaneConstraint…?

1 Like

I don’t think I explained this quit right. The current system I’m using to lock attachments to the 2D plane breaks if the parent exits that plane. Even if I use a PlaneConstraint, there will problably be some case where the parent might still exit the plane for a single frame which will create an offset everytime it happens.

Also in my case, I still want the parent to be able to rotate in a way that exits the plane in which case the same issue will happen but this time in intended conditions.

1 Like