Hello to everyone reading this!
I have a model made up of various ‘cube’ elements. I read in another forum that in order to import a model directly as a collider i could add <Collide> { Polyset keep descend }
to under the desired <group>
. Therefore, I have done so and don’t seem to be facing any errors. Now my question is, how do I proceed from here and actually make things collide in the scene? What code do I need to write in order to do that? I’ll attach a snippet of the relevant code to this post.
self.room = self.loader.loadModel("models/gaming_room(3)")
self.room.reparentTo(self.render)
self.room.setScale(5)
self.room.setPos(30, 0, 0)
As you can see above, I haven’t really done anything to make my model a collider in the code itself but that is because I don’t really know what to do.
self.cTrav = CollisionTraverser()
ray = CollisionRay()
ray.setFromLens(self.camNode, (0, 0))
rayNode = CollisionNode('line-of-sight')
rayNode.addSolid(ray)
rayNodePath = self.camera.attachNewNode(rayNode)
self.rayQueue = CollisionHandlerQueue()
self.cTrav.addCollider(rayNodePath, self.rayQueue
I found the above code on youtube to convert my camera into a collider. Presently, that is the only collider in my scene.
Thank you!