This is an object from a greater class i have been unable to get to work to create multiple addressable cubes. I first tried making a separate class (init and update) to circumvent this issue. However then I couldn’t address “bullet world” so i couldn’t actually add physics to the cubes. However the issue with this code is I can’t address the cubes in the update object individually to let the player control one of the cubes, not all of them. Any help would be greatly appreciated…
def createBox(self, x, y, z):
# Box (dynamic)
shape = BulletBoxShape(Vec3(0.5, 0.5, 0.5))
self.boxNP = self.worldNP.attachNewNode(BulletRigidBodyNode('Box'))
self.boxNP.node().setMass(1.0)
self.boxNP.node().addShape(shape)
self.boxNP.setPos(x, y, z)
#self.boxNP.setScale(2, 1, 0.5)
self.boxNP.setCollideMask(BitMask32.allOn())
#self.boxNP.node().setDeactivationEnabled(False)
self.world.attachRigidBody(self.boxNP.node())
visualNP = loader.loadModel('Models/Box/plainbox.egg')
visualNP.clearModelNodes()
visualNP.reparentTo(self.boxNP)