Hey all,
Im trying to create a collisionSegment between my player’s NodePath and my camera. I was looking through the api documentation about collisionSegments and their defined by the (x,y,z) of 2 points a and b. so i have the following code
def initCameraCollisions(self):
#self.cnodePath = base.camera.attachNewNode(CollisionNode('CollisionSphereCamera'))
#self.csphere = CollisionSphere(0, 0, 0, 4)
#self.cnodePath.node().addSolid(self.csphere)
#self.cnodePath.node().setFromCollideMask(BitMask32.bit(1))
#self.cnodePath.node().setIntoCollideMask(BitMask32.allOff())
#base.cTrav.addCollider(self.cnodePath, self.hitBoxCollEvent)
#self.accept('into-' + 'CollisionSphereCamera', self.cameraCollision)
self.rayNode = self.playerNP.attachNewNode(CollisionNode('rayCollide'))
self.cSegment = CollisionSegment(self.playerNP.getX(), self.playerNP.getY(), self.playerNP.getZ(), base.camera.getX(), base.camera.getY(), base.camera.getZ())
self.rayNode.node().addSolid(self.cSegment)
base.cTrav.addCollider(self.rayNode, self.rayCollEvent)
self.accept('rayCollide-into', self.cameraCollision)
def cameraCollision(self, collEntry):
#base.camera.setY(base.camera.getY() + 1)
#base.camera.setZ(base.camera.getZ() - 1)
base.camera.setPos(collEntry.getSurfacePoint(render))
print("camera Collided")
but that yeilds an error of
Running: C:/Users/Flips/Documents/Jutsu's/VoxelDash/main.py (Wed Oct 03 20:57:14 2012)
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
destroying Menu
Assertion failed: _a != _b at line 53 of c:\buildslave\dev_sdk_win32\build\panda3d\panda\src\collide\collisionSegment.I
Assertion failed: _ref_count == 0 || _ref_count == local_ref_count at line 129 of c:\buildslave\dev_sdk_win32\build\panda3d\built\include\referenceCount.I
Traceback (most recent call last):
File "C:\Panda3D-1.9.0\direct\showbase\EventManager.py", line 61, in eventLoopTask
self.doEvents()
File "C:\Panda3D-1.9.0\direct\showbase\EventManager.py", line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File "C:\Panda3D-1.9.0\direct\showbase\EventManager.py", line 122, in processEvent
messenger.send(eventName, paramList)
File "C:\Panda3D-1.9.0\direct\showbase\Messenger.py", line 397, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "C:\Panda3D-1.9.0\direct\showbase\Messenger.py", line 484, in __dispatch
self.lock.acquire()
File "C:\Panda3D-1.9.0\direct\stdpy\threading.py", line 187, in acquire
pm.Mutex.acquire(self)
AssertionError: _ref_count == 0 || _ref_count == local_ref_count at line 129 of c:\buildslave\dev_sdk_win32\build\panda3d\built\include\referenceCount.I
:task(error): Exception occurred in PythonTask eventManager
Traceback (most recent call last):
File "C:/Users/Flips/Documents/Jutsu's/VoxelDash/main.py", line 157, in <module>
app.run()
File "C:\Panda3D-1.9.0\direct\showbase\ShowBase.py", line 2921, in run
self.taskMgr.run()
File "C:\Panda3D-1.9.0\direct\task\Task.py", line 502, in run
self.step()
File "C:\Panda3D-1.9.0\direct\task\Task.py", line 460, in step
self.mgr.poll()
File "C:\Panda3D-1.9.0\direct\showbase\EventManager.py", line 61, in eventLoopTask
self.doEvents()
File "C:\Panda3D-1.9.0\direct\showbase\EventManager.py", line 55, in doEvents
processFunc(self.eventQueue.dequeueEvent())
File "C:\Panda3D-1.9.0\direct\showbase\EventManager.py", line 122, in processEvent
messenger.send(eventName, paramList)
File "C:\Panda3D-1.9.0\direct\showbase\Messenger.py", line 397, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "C:\Panda3D-1.9.0\direct\showbase\Messenger.py", line 484, in __dispatch
self.lock.acquire()
File "C:\Panda3D-1.9.0\direct\stdpy\threading.py", line 187, in acquire
pm.Mutex.acquire(self)
AssertionError: _ref_count == 0 || _ref_count == local_ref_count at line 129 of c:\buildslave\dev_sdk_win32\build\panda3d\built\include\referenceCount.I
Execution Successful!
I didnt see antything about the name of the collision Segment in the api docs so i didnt know how to get the string of the collision event of the segment so i tried adding it as a solid to a collisionNode that does have a name. Is that the issue? Could i maybe get some form of an example of collision segments? Also if my player and camera are moving will i have to update the pos of point a and b of the collisionSegment to reflect that? Sorry lots of questions