Post by alexluciani on May 17, 2011 15:23:49 GMT -5
Hi to all,
for the assignment project I'm creating an environment with some elements where the camera collides with them. So, if the camera collides the floor I want to put it at a certain distance from the collision point, and if the camera collides the lava then the game is over. So for every kind of collision there is a different method to call.
My problem is about the definition of the handlers for every type of collision. I wrote this code:
In particular these two rows don't work:
They work only if I put, as first parameter, the self.cameracollider node. But in this case they don't do what I want (for example they call the game over just walking on the normal floor ).
Does anyone tried a different solution? Or solved it?
Thanks to all, good night
for the assignment project I'm creating an environment with some elements where the camera collides with them. So, if the camera collides the floor I want to put it at a certain distance from the collision point, and if the camera collides the lava then the game is over. So for every kind of collision there is a different method to call.
My problem is about the definition of the handlers for every type of collision. I wrote this code:
self.lavacollider = self.lava_ocean_node.attachNewNode(CollisionNode('lavacol'))
self.lavacollider.node().addSolid(CollisionPolygon((0,0,0),(2,0,0),(2,-2,0),(0,-2,0)))
self.lavacollider.show()
self.platform1collider = self.platform1_node.attachNewNode(CollisionNode('platform1col'))
self.platform1collider.node().addSolid(CollisionPolygon((0,0,1),(3,0,1),(3,-3,1),(0,-3,1)))
self.platform1collider.show()
self.cameracollider = base.camera.attachNewNode(CollisionNode('camcol'))
self.cameracollider.node().addSolid(CollisionSphere(0,0,1,1))
self.collLavaHandler = CollisionHandlerEvent()
self.collLavaHandler.addInPattern('camera-into-lava')
self.collPlatform1Handler = CollisionHandlerEvent()
self.collPlatform1Handler.addInPattern('camera-into-platform1')
base.cTrav = CollisionTraverser('world traverser')
base.cTrav.addCollider(self.lavacollider, self.collLavaHandler)
base.cTrav.addCollider(self.platform1collider, self.collPlatform1Handler)
self.accept('camera-into-lava', self.gameover)
self.accept('camera-into-platform1', self.cameraUp)
In particular these two rows don't work:
base.cTrav.addCollider(self.lavacollider, self.collLavaHandler)
base.cTrav.addCollider(self.platform1collider, self.collPlatform1Handler)
They work only if I put, as first parameter, the self.cameracollider node. But in this case they don't do what I want (for example they call the game over just walking on the normal floor ).
Does anyone tried a different solution? Or solved it?
Thanks to all, good night