- Home /
2D Platforme Rope
Hi I´ve been trying to implement a rope/grappling system in a unity 2d game. The Player is supposed to shoot a rope and swing from one wall to another. For this purpose i shoot an object with a line renderer for the visuals and once it hits a wall i enable a distance joint (between object and player) for the "physics". Now the basics of swinging etc. work, but it doesn´t really behave like a rope. These are some of the problems:
Gravity doesn´t work properly. the player is not pulled down at all, and it looks really strange when your standing suspended in mid-air at 45° as if the rope is some kind of stick :-)
It is possible to stand on the rope if you shoot it under yourself.
I can change the direction of my Swing in mid-air without any kind of delay
Now i am not entirely sure how i can fix this. I had the idea of generating a rope consisting of many joints dependant on the distance to a wall etc. but i don´t know how to do this. How could i make it behave like i want it to.
Thanks in advance for all answers
P.S.: Sry if this question seems a bit vague
EDIT: Problem 2 has been solved. Problem 1 is the worst one. How can i make the joint behave more fluently and pull the player down instead of suspending him in the air?
Answer by daneislazy · Feb 08, 2015 at 07:04 PM
You probably want to use a HingeJoint2D
instead. Set the Anchor position to where you want the rope to attach to in the player's world space, so you can do something like targetPosition - playerPosition
to get that. It should work fine with 2D and gravity. You may also want to pre-rotate the player slightly or compensate the rotation as you swing.
As for the changing direction thing, you will probably need to change your movement script to lessen the effects of player input.
Ok so i tested it and it turned out that part of the character controller was causing the problems. So now everything works fine, even with a distance joint. Thanks for the answer though!