Detecting walls using ray casts / collision lines

Hi. I am creating a simulation where the agent in the sim will be solving mazes using a maze solving algorithm called the hand on the wall algorithm, this is where the agent puts their hand on either left or right side wall and follows the wall until the end of the maze. To do this I know I am going to have to be able to sense the walls and it was mentioned to me that using ray casts is the best way to do this, unfortunately i am very inexperienced with panda3D and I don’t really know where to go next here is the code i have so far :

   def senseWall(self, task):
        self.eyes = self.player.exposeJoint(None, "modelRoot", "fps_eyes")

        eyePos = self.eyes.getPos()


        eyeRay = CollisionRay(eyePos, LVecBase3(0,180,0))
        return task.cont

I get the position of the eyes from the character controller and then cast a ray from the eyes of the character but I don’t know what the next step is, would anyone please be able to help me

Hmm… If you want the character to “keep their hand on the left wall”, surely you want to detect whatever is to the left of the character?

Otherwise, you have a collision-ray, the next thing would presumably to have your collision traverser to traverse the scene, and then see what you collision hander reports of the results.

By the way, you likely don’t need to create the collision-ray every time that the task is run; it might be more efficient to create it just once, when the character is created, and then just use it in the task.

It doesn’t have to be their left hand exclusively, it can be either the left or right hand

By the way, you likely don’t need to create the collision-ray every time that the task is run; it might be more efficient to create it just once, when the character is created, and then just use it in the task.

Would it be better to create the collision ray when I instantiate the player and not in the task its self

That’s fair–but my point is that, either way, I’d imagine that you’d want a ray pointing in that direction.

I don’t know about better–that depends on what you would consider to be better. I’m rather saying that it might be more efficient, and that conversely re-creating the ray on each task-update is unnecessary.