Strange behaviour with physics joints

#1

I’ve attached an empty project with nothing changed aside from two game objects added, one with a dynamic collision object and one with a static collision object. One of the objects has a script that creates a fixed joint for the two objects.

joints-test.zip (17.1 KB)

The result looks like this on my end, with some very strange movement from the dynamic object:

02%20pm

I’m not familiar with physics at all, so I don’t understand why this happens, but it definitely doesn’t seem intended. Any thoughts?

EDIT: This is from Defold version 1.2.173, running on macOS.

0 Likes

#2

I don’t think this is a bug… The position that you give for the joints in the physics.create_joint function is a local position. When you told the game objects to get their own position for the location to place the joints, they doubled their position vectors.

This is how I got it to work:

	local pos_1 = go.get_position()
	local pos_2 = go.get_position("go2")
	physics.create_joint(
		physics.JOINT_TYPE_FIXED,
		"/go1#collisionobject",
		"rope",
		pos_2 - pos_1,
		"/go2#collisionobject",
		vmath.vector3()
	)
0 Likes