Collision traverser error [SOLVED]

In my game, I have implemented a class, called Kid, for characters which loads their model and puts a collision sphere around them. I also made a class called MouseRay which creates a collision ray, a traverser, a handler, and so forth to use for mouse picking.

In the MouseRay class, I have a function to use for performing the actual collision checking. It looks like this:

def collisionTest(self, testNode):
		#This function takes a base node and checks that node and it's children for collision with the mouse ray. It also makes
		#sure that the ray is positioned correctly and aimed at the mouse pointer.
		
		if base.mouseWatcherNode.hasMouse():
			#We must check to make sure the window has the mouse to prevent a crash error caused by accessing the mouse
			#when it's not in the window.
			
			mpos = base.mouseWatcherNode.getMouse()
			#get the mouse position in the window
			
			self.collideRay.setFromLens(base.camNode, mpos.getX(), mpos.getY())
			#sets the ray's origin at the camera and directs it to shoot through the mouse cursor
			
			self.collideTraverser.traverse(testNode)
			#performs the collision checking pass
			
		return

When I pass a Kid object into this collision function to be tested, I receive the error “.traverse() argument 1 must be nodepath, not instance”

The end goal is to have many Kids passed into this function at once as children of a dummy node. Currently, the Kid class doesn’t derive from any existing classes. Should I make the Kid class inherit from the NodePath class, or some other class, so I can reparent them to a dummy node?

collisionTraverser.traverse() wants to receive a NodePath as its parameter: the root of the tree that it will walk, looking for “into” nodes.

I don’t know what you intend to pass there, but if you want to traverse only your Kid’s model, you could call something like traverse(kid.model). That is, your Kid doesn’t have to be a NodePath in order for it to have a NodePath.

David

You saved me again, David. I was able to attach the model created in the Kid class to a dummy node and feed that into the traverser. Using that method, I should be able to devise a way to limit which kids are being checked for mouse picking based on the region their located in, or something.