- Home /
distance joint 2d exceeding distance when pulling straight up
I want my character to get pulled up to a certain point, but when I do this the player freezes on the way towards the anchor point. The distance value does still goes down. The only time this happens is when im making it go straight up, any other angle works fine.
You can see the small line above the cube is the distance value and where the cube is supposed to be. Its important to note that the cube goes up a certain distance before stopping like this.
code: public class grapple : MonoBehaviour { public DistanceJoint2D joint; public playermovement movementscript;
public float pullspeed = 0.005f;
public bool isgrappling = false;
void Start()
{
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
startgrapple();
}
if (Input.GetMouseButtonDown(1))
{
endgrapple();
}
if (isgrappling)
{
grappling();
}
}
void startgrapple()
{
movementscript.enabled = false;
joint.enabled = true;
isgrappling = true;
}
void endgrapple()
{
joint.enabled = false;
isgrappling = false;
movementscript.enabled = true;
}
void grappling()
{
joint.distance = joint.distance - pullspeed;
}
}
does anyone know what the problem is?
Your answer
Follow this Question
Related Questions
2D Animation does not start 1 Answer
Set Light2D sprite via scripting 1 Answer
Rebounding Hinge Joint 2D 0 Answers
Make a hinge joint stay firmly in place 4 Answers
Create hinge joint 2D by collision 2 Answers