def setupRay(self, bitmask, floorOffset, reach):
     cRay = CollisionRay(0.0, 0.0, 3.0, 0.0, 0.0, -1.0)
     cRayNode = CollisionNode('Flyer.cRayNode')
     cRayNode.addSolid(cRay)
     self.cRayNodePath = self.avatarNodePath.attachNewNode(cRayNode)
     cRayNode.setFromCollideMask(bitmask)
     cRayNode.setIntoCollideMask(BitMask32.allOff())
     self.lifter = CollisionHandlerGravity()
     self.lifter.setLegacyMode(self._legacyLifter)
     self.lifter.setGravity(self.getGravity(0))
     self.lifter.addInPattern('%fn-enter-%in')
     self.lifter.addAgainPattern('%fn-again-%in')
     self.lifter.addOutPattern('%fn-exit-%in')
     self.lifter.setOffset(floorOffset)
     self.lifter.setReach(reach)
     self.lifter.addCollider(self.cRayNodePath, self.avatarNodePath)
Exemplo n.º 2
0
snipstuff.info.append(
    "Try to reach the top of the windmill\n\nwasd=move the avatar around\nSPACE=avatar jump"
)
snipstuff.info_show()

#=========================================================================
# Main
""" As suggested above, we're going to use what we learned so far to make collide 2d and 3d objects. By the way there is nothing special to do from 3d-3d collisions cos the colliders and handlers used are exactly the same as you'll see.
"""
#=========================================================================

#** Collision system ignition
base.cTrav = CollisionTraverser()

#** This is the known collision handler we use for floor collisions. We'll keep going with the usual settings here as well.
avatarFloorHandler = CollisionHandlerGravity()
avatarFloorHandler.setGravity(9.81 + 25)
avatarFloorHandler.setMaxVelocity(100)

#** the walls collider
wallHandler = CollisionHandlerPusher()

#** we'll use this to 'sense' the fallout impact velocity and also to 'read' various triggers we've put around the map for several purposes.
collisionEvent = CollisionHandlerEvent()

#** Collision masks - this time there is a new one: the TRIGGER_MASK is used to detect certain collision geometry to act as a trigger, therefore we need to distinguish'em from floor and walls.
FLOOR_MASK = BitMask32.bit(1)
WALL_MASK = BitMask32.bit(2)
TRIGGER_MASK = BitMask32.bit(3)

#** Our steering avatar