Hi, I have a simple game I’m working on where the player is a sphere and there are boxes (houses) on the ground. I have been able to use the CollisionHandlerPusher class to prevent the player from walking through buildings.
However, I am now trying to add a new feature: when the player is close enough to a house, the door opens. To do this, I have added a collision sphere to the house. I want the player to be able to walk through this sphere (this sphere just detects if the player is close enough for the door to open).
However, because of the way the CollisionHandlerPusher handles collisions, this sphere is pushing the player as well. Any suggestions?
My code basically looks like this:
house = loader.loadModel(‘house’)
house.reparentTo(render)
house.setPos(0, 10, 0)
houseNode = house.attachNewNode(CollisionNode(‘wallnode’))
south_wall = CollisionPolygon # appropriate arguments here
houseNode.node().addSolid(south_wall)
similar code for other walls
player = loader.loadModel(‘player’)
player.reparentTo(render)
player.setPos(0, 0, 0)
fromObject = player.attachNewNode(CollisionNode(‘playernode’))
fromObject.node().addSolid(CollisionSphere(0, 0, 0, 1))
pusher = CollisionHandlerPusher()
pusher.addCollider(fromObject, player)
base.cTrav = CollisionTraverser()
base.cTrav.addCollider(fromObject, pusher)
Sorry if this is in the wrong place, let me know where it should go