make GameObject follow another

In my game, there is a rope that swings left and right.

I want the player to grab this rope and follow it perfectly.

What I did: as my rope has a lot of little pieces, when the player grab it, I set the last piece of the rope to be the parent of the player’s transform, and I thought this should work but it didn’t, probably because my player has a rigidbody2D attached… The parts of the rope also have ridibody2D.

What approach should I use to make the player follow the last piece of the rope perfectly?

I think “to be the parent” was the good solution. Maybe you should just disable the rigidbody if the player is on the rope?GetComponent().enabled = false;
or overwrite the players position with needed position from the rope.
transform.position = rope.transform.position;

I don’t think you can actually disable a rigidbody component (might be wrong?), but you can take it out of the simulation like GetComponent<Rigidbody2D>().simulated = false. Another option is to create a joint on the fly and actually attach the player to the rope.

1 Like

I already tried to attach a hinge joint in the player but this led me to so many bugs I won’t be able to describe in just one life (and I didn’t try for 3 hours or so, I spent about a week trying to let it fluid but it always came up with critical bugs).
I thought that this “enabled” solution should not be feasible cos I guess rigidbody2d cannot be disabled anymore, but I’ll try this .simulated solution and see if it works.