After I move a BulletRigidBodyNode , I can't click it

def __init__(self):
		ShowBase.__init__(self)
		self.world = BulletWorld()
		base.disableMouse()
		self.map = Map2()
		# 显示所有节点
		self.squareRoot = render.attachNewNode("squareRoot")
		self.squareRoot.reparentTo(render)
		# 节点保留路径位置
		self.pathPos = []
		for i in self.map.path:
			tools = loader.loadModel("egg/tiles")
			tools.setHpr(i[4],0,0)
			# 设置标签
			tools.setTag('CollisionTag', str(i))
			tools.find("**/polygon").node().setIntoCollideMask(BitMask32.bit(1))
			# 设置 Bullet 的静态物体
			shape = BulletBoxShape(Vec3(1,1,0.1))
			self.pathPos.append(BulletRigidBodyNode('BulletBox'))
			self.pathPos[-1].addShape(shape)
			np = render.attachNewNode(self.pathPos[-1])
			np.setPos(i[0],i[1],i[2])
			self.world.attachRigidBody(self.pathPos[-1])
			# 将模型加入碰撞物体
			tools.reparentTo(np)

		# 当前选择的物体
		self.pathFocus = self.pathPos[0]

The self.pathFocus is selected object .

	def mouse1(self):

		# 获得鼠标的位置
		mpos = base.mouseWatcherNode.getMouse()
		# 获得两个点
		pFrom = Point3()
		pTo = Point3()
		base.camLens.extrude(mpos, pFrom, pTo)
		# 转换为全局坐标
		pFrom = render.getRelativePoint(base.cam, pFrom)
		pTo = render.getRelativePoint(base.cam, pTo)
		# 根据鼠标的位置设置碰撞射线的位置
		result = self.world.rayTestClosest(pFrom, pTo)
		self.pathFocus = result.getNode()
		self.setAllColor()

I use mouse1 change self.pathFocus

	def moveL(self):
		node = render.attachNewNode(self.pathFocus)
		node.setPos(node.getPos()+(-1,0,0))
	def moveR(self):
		node = render.attachNewNode(self.pathFocus)
		node.setPos(node.getPos()+(+1,0,0))

When I called moveL or moveR , them click it , the self.pathFocus = null .
By the way , I use panda3d1.8_1.8.0+cvs20110810~natty67_amd64 .

Problem-solving

	def moveL(self):
		node = render.attachNewNode(self.pathFocus)
		print self.pathFocus
		node.setPos(node.getPos()+(-1,0,0))
		self.world.removeRigidBody(self.pathFocus)
		self.world.attachRigidBody(self.pathFocus)
		
	def moveR(self):
		node = render.attachNewNode(self.pathFocus)
		node.setPos(node.getPos()+(+1,0,0))
		self.world.removeRigidBody(self.pathFocus)
		self.world.attachRigidBody(self.pathFocus)
	def moveF(self):
		node = render.attachNewNode(self.pathFocus)
		node.setPos(node.getPos()+(0,+1,0))
		self.world.removeRigidBody(self.pathFocus)
		self.world.attachRigidBody(self.pathFocus)
	def moveB(self):
		node = render.attachNewNode(self.pathFocus)
		node.setPos(node.getPos()+(0,-1,0))
		self.world.removeRigidBody(self.pathFocus)
		self.world.attachRigidBody(self.pathFocus)
	def moveU(self):
		node = render.attachNewNode(self.pathFocus)
		node.setPos(node.getPos()+(0,0,+1))
		self.world.removeRigidBody(self.pathFocus)
		self.world.attachRigidBody(self.pathFocus)
	def moveD(self):
		node = render.attachNewNode(self.pathFocus)
		node.setPos(node.getPos()+(0,0,-1))
		self.world.removeRigidBody(self.pathFocus)
		self.world.attachRigidBody(self.pathFocus)

I would like to suggest another way of handling your case.

First, we should look at the problem. The raytest result method “getNode” returns a PandaNode. You store this node in self.pathNode. Later, inside “moveL” etc. you want to modify the node’s transform. This can be done in two ways:
(1) node.getTransfrom --> create a new TransformState based on the one returned --> node.setTransform
(2) get a NodePath handle to the node, the use setPos on the NodePath.

The second method is more convenient, usually, since most users don’t want to mess with TransformStates.

What you do is neither of the to ways; you attach the node a second time to the scene graph (render.attachNewNode), which returns a NodePath to the newly attached node. Then you use setPos on this new nodePath. The problem is that you effectively create a new node in the scene graph.

This is how it can be done better:
(1) don’t store the node returned by the raycase, but a handle to it:

result = self.world.rayTestClosest(pFrom, pTo)
resultNode = result.getNode()
resultNP = NodePath.anyPath(node)
self.pathFocus =  resultNP

(2) Now you just have to call setPos on self.pathFocus, since this member is now a NodePath (and not a PandaNode).

def modelL(self):
    self.pathFocus.setPos(self.pathFocus, Point3(-1,0,0))

Oh, and you should definitely add some code which catches the case when you raycast doesn’t hit a body (empty result, getNode returns None).

Thank you ! Before I stranger to anyPath() .