def EnvironmentCollide(self):
#This sets up the collisions as edited in the environment.egg file
# this tells panda its a geom collision node
TreeTrunk = self.environ.find("**/TreeTrunkcoll")
cNode = CollisionNode('TreeTrunk')
cNode.addSolid(CollisionSphere(0,0,0,1.1))
CNodePath = TreeTrunk.attachNewNode(cNode)
cNodePath.setIntoCollideMask(BitMask32.allOff())
cNodePath.show()
# end EnvironmentCollide
Produces
C:\testgame>ppython main.py
Warning: DirectNotify: category 'Interval' already exists
DirectStart: Starting the game.
Known pipe types:
wglGraphicsPipe
(3 aux display modules not yet loaded.)
Assertion failed: _error_type == ET_ok at line 488 of panda/src/pgraph/nodePath.
cxx
Traceback (most recent call last):
File "main.py", line 195, in ?
w= World()
File "main.py", line 35, in __init__
self.EnvironmentCollide()
File "main.py", line 186, in EnvironmentCollide
CNodePath = TreeTrunk.attachNewNode(cNode)
AssertionError: _error_type == ET_ok at line 488 of panda/src/pgraph/nodePath.cx
x
Even when I edit the code and do get into the game, I can’t see the collision nodes that are set up, so somewhere something is not being picked up.
C:\testgame>ppython main.py
Warning: DirectNotify: category 'Interval' already exists
DirectStart: Starting the game.
Known pipe types:
wglGraphicsPipe
(3 aux display modules not yet loaded.)
Traceback (most recent call last):
File "main.py", line 198, in ?
w= World()
File "main.py", line 35, in __init__
self.EnvironmentCollide()
File "main.py", line 187, in EnvironmentCollide
cNodePath.setIntoCollideMask(BitMask32.bit(1))
AttributeError: 'libpanda.NodePath' object has no attribute 'setIntoCollideMask'
but whilst it is working now, i still cannot see any sort of node around the treetrunk and can still walk through it (although to be honest getting the mode working first is my main priority!)
But, if you’re about to make your walking character stop when hit the environment, why do you use the collision sphere for the environment ?
You can just set the whole environment to collide with the character, coz the environment only consist of simple polygons.
TreeTrunk.setCollideMask(Bitmask32.bit(1))
About still walking through it :
have you create and set the from-node to collide with the into-node ?
The from-node and the into-node must have at least 1 bit in common, so that they are ‘visible’ to each other. In this case, you must set the bit(1) for the from-node. You must parent the from-node to your walking character. The next thing, you must check the collision entries, whether there are collisions, and then decide what will happen next. Will the character simply stop, or slide to the side. You may want to use the pusher traverser instead. But regarding to my own experience using pusher, sometimes the from-node passes through the into-node, even after using the setFluidPos() and setRespectPrevTransform(True).