Here’s the solution to your issue- a word of advice though- you may want to search for keywords about your problems as this specific issue has been dealt with quite a bit.
def map3dToAspect2d(self, node, point): # it converts between objects on the screen and their 3D location for comparasion.
"""Maps the indicated 3-d point (a Point3), which is relative to
the indicated NodePath, to the corresponding point in the aspect2d
scene graph. Returns the corresponding Point3 in aspect2d.
Returns None if the point is not onscreen. """
# Convert the point to the 3-d space of the camera
p3 = base.cam.getRelativePoint(node, point)
# Convert it through the lens to render2d coordinates
p2 = Point2()
if not base.camLens.project(p3, p2):
return None
r2d = Point3(p2[0], 0, p2[1])
# And then convert it to aspect2d coordinates
a2d = aspect2d.getRelativePoint(render2d, r2d)
return a2d