Why won't the Genaric6DOFjoint work when made on runtime?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Merlin1846

I have been trying to make it so that I can create a cube and it will attach to whatever is passed into the function. But when I run it everything works fine, I can make towers of blocks, they collide, all of that but the joint doesn’t do anything. I have tried various methods of creating and attaching the joint but nothing changes, I am not even getting errors.

Anyone have any idea what could be wrong?

#position = the position of new object, baseObject = a referance to the object that this 
one will be attacthed to.

func createObject(position,baseObject):
 position = position.snapped(Vector3(1,1,1)*gridScale)
 var object = RigidBody.new()
 var collision = CollisionShape.new()
 collision.shape = BoxShape.new()
 collision.shape.extents = Vector3(0.5,0.5,0.5)
 object.translation = position
 var objectCSG = CSGBox.new()
 objectCSG.width = 1
 objectCSG.height = 1
 objectCSG.depth = 1
 var joint = Generic6DOFJoint.new()


Sorry about the weird indenting, but the text wrap is messing with it.

As a side note, it’s recommended to avoid using CSG nodes when you’re not performing boolean operations as their UV mapping is less flexible. Instead, use a MeshInstance with a CubeMesh resource assigned to its mesh property (this can be done via code too).

Calinou | 2021-05-09 08:49

:bust_in_silhouette: Reply From: Merlin1846

Don’t know why but replacing the code that adds the joint with this fixed it.

var joint = Generic6DOFJoint.new()