Fixed joint 2d enable/disable

Im trying to make a game where the player is a possum and at some point it need to put baby possuns in its back, im trying to do this with fixed joints 2d. I tried starting with the baby in the back, and when i pressed a button it set, it sets the fixedjoint2d.enabled = false; by script, but when close enough, applying fixedjoint2d.enabled = true; it didnt work to put the baby back in the back of the player, i dont know if there is a better way to do what i want, and dont know what im doing wrong for it dont enable the joint after i pressed the button, i already tested and the input is correct and the trigger for the baby is right as well

With the 3D physics system there isn’t even a .enabled property…

The reference way to break a 3D joint is to Destroy() or DestroyImmediate() it, then recreate it when you need it again.

I see with the 2D physics system that .enabled exists but perhaps it doesn’t do anything.

Perhaps try Destroy()-ing and recreating the joint yourself.

Perhaps our resident 2D fizz wizard @MelvMay could weigh in on the above?

This doesn’t provide any information though so you’ll need to explain what isn’t working.

Before you enable a joint, you have to ensure it’s set-up correctly. Also, don’t forget that by default it’s set to auto-configure the anchor points so if the “possum” is somewhere else, it’ll continue to ensure it’s at a fixed position where it is. Maybe this is what you mean by “it didn’t work”?

If you are continually enabling/disabling then ensure you turn this off before you enable it or just turn it off in the inspector but understand what it’s for as it can be critical if you’re connecting things up dynamically as you seem to be doing.

If this isn’t the issue then please explain what is not working, maybe show some images/video … we all love images and video. :slight_smile:

yeah i needed to be more specific, what i mean with ‘‘it didnt work’’ was i was able to disable the joint (i was starting the game with the ‘‘baby possum’’ already in the back, in the fixed joint, then i press the button, it disable the joint and the baby goes to the ground, but when i come closer to the baby to attach it in the back again, the joint never gets enabled again, it only works if i manually click to enable it in the inspector again, i tested all other variables, if the trigger is set correctly, the input of the button, i hope this time i didnt forget any important detail about my problem, thanks for taking your time to help me

I think again you’re indirectly describing something. You say it doesn’t get enabled again but it will without issue so I ask, how do you know it’s not enabled? This is the point of describing the actual problem you’re having, not what you think is happening i.e. the joint isn’t being enabled.

Forget the joint, what is actually happening? I cannot help you figure out what you think is happening, only help with a specific problem.

Also, did you read what I put before? If you just enable it, it’ll keep it where it currently is.

i know its not enabled from what appears in the inspector, when i press to detach the baby, in the inspector the checkbox goes blank, when i press it back, the checkbox doesnt change, when i click in the checkbox in the inspector the baby return to the back, the auto configure is off, what is happening is that the baby just stay where he was left, it only return to the back when i manually enable the joint through the inspector checkbox of the joint, that checkbox in the inspector is the only way i know to check if the joint is enabled or not

That’s not controlled by physics or 2D, it’s a low-level component thing in Unity controlled with Behaviour.enabled so no idea why it’s not enabling. Lots of component inherit from this.

It does sound like you’ve got code that’s constantly asserting it disabled after you disable it but you could obviously quickly check that by spinning up a new project or GameObject and trying the same on it.

Alternately, if youv’e got your break-limit set to disable, it could be that which is disabling it but you get a callback for that or you might not have it set to disable or not be using it. No idea, I’ve not seen script or images.

My point was, it’s only just now that you’ve actually stated what the problem is that the check-box is not showing as checked when you enable it. For all we know you could’ve been talking about the joint not working.

got it, sorry for the misleading info and thanks for your time helping me, i tried now with other component and it didnt enabled it too, i dont know why, i saw some people saying that creating a empty gameobject with a rigidbody and switching to that when i wanted to release (in my case that baby possum) was an option, but im not sure what makes that switch from one rb to another, but probably ill move to the destroy and instantiate a new joint and see if i can make it work

If you couldn’t enable components then there’d be dev with pitchforks out so something else is going on here.

Do you have a simple reproduction project you could send so I could look at it for you? Ideally remove the library folder so it isn’t massive.

im sorry i didnt see it early, i dont know if i have a backup of it actually, but i made it work conceptually what i wanted using a much simpler idea that i dont know how i didnt think of it earlier
its a simple sprite swap dependent in a bool to check if ur holding the baby or not, when triggerenter the baby on the ground, switch sprite, and destroy the baby, when holding the baby, switch to basic sprite and instantiate the baby in front of the player
Test.gif-ezgif.com-video-to-gif-converter
i will check if i have a backup with the code that i was struggling with, bc itll be good to learn what i was doing wrong