Attention | Topic was automatically imported from the old Question2Answer platform. | |
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.add_child(collision)
object.translation = position
var objectCSG = CSGBox.new()
objectCSG.width = 1
objectCSG.height = 1
objectCSG.depth = 1
object.add_child(objectCSG)
$Creations.add_child(object,true)
var joint = Generic6DOFJoint.new()
baseObject.add_child(joint,true)
joint.call_deferred("set_node_a",get_path_to(baseObject))
joint.call_deferred(“set_node_b”,get_path_to($Creations.get_child($Creations.get_child_count()-1)))
#joint.set_node_a(get_path_to(baseObject))
#joint.set_node_b(get_path_to($Creations.get_child($Creations.get_child_count()-1)))
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