Creating Distance Joint dynamically

Creating Distance Joint dynamically
0.0 0


I’m using cocos creator v1.6 to make a game for website and native.
I want to instantiate nodes at the top of the Canvas and make them fall with gravity, and, when they collide with a node at the bottom of the Canvas (let’s call it baseNode), create a distance joint component in the falling node and set the connectedBody property as the rigidbody of the baseNode.

I was succesfull on that task, I inspected element and the property connectedBody was actually the baseNode rigidbody but nothing happened in the game, the falling node is moving like it doesn’t have any Distance Joint atached. :confused:

I’ll appreciate any kind of suggestion.

Many thanks :smiley:

@slackmoehrle any tips?


I am not sure. Let us ask @jare if one of the engineering team members can take a look at your post.


Thanks man I really appreciate it :ok_hand:


This example shows how to create joint dynamically. Maybe it can help you.


Thank you! It worked perfectly :smiley:
I was seting it’s properties directly, like: this.node.addComponent(cc.DistanceJoint) and then this.node.getComponent(cc.DistanceJoint).connectedBody = other.node. I don’t know why it doesn’t work this way, but putting the addComponent inside a let works fine.