Keep on Walking

Aaron Black
2 min readNov 29, 2020

--

I have been making some good progress the past couple of days until this evening. I have worked through the players movements which were pretty familiar to me. I used Raycasting using a Ray from the camera triggered by a left mouse click. I set a position for it in a RaycastHit object so Darren would know where to go. Then, I used SetDestination() to manipulate the Nav Mesh Agent to send Darren to that point. I could do all of this because I put a NavMesh Agent on Darren and baked the floor so he would know where all of the glass cases were, or better said, where the floor was and wasn’t so he would only walk there. This is what the code looks like for moving Darren around the room:

Right now I am working on my guards AI system.As smoothly as it went getting Darren to move, I am having trouble dialing in the guards perfectly. At one point all the guards were dancing around, swinging there flashlights everywhere. It actually looked like a pretty sweet club scene except one of the guards were just standing there in the middle of the floor in the idle position. Pretty much that one guy that can’t dance at the club but wants to be on the dance floor anyways.

I slowly started getting them working properly. I used a similar system of manipulating the NavMesh Agent component on them using SetDestination() to give them somewhere to go. This time instead of Raycasting I put points in a List with different point in the room set for each guard to cycle through.

I got all of the guards working the way I wanted to except one. He was the boring guy in the club, but it seems he got inspired to move. His animation isn’t working properly. For some reason I cannot get him to go to idle and stay there. He stays at his position but keeps the walk animation on. The rest of the guards work great, they walk , idle, go to their waypoints I set. I will give it another crack in the morning but will move on to the coin toss for now. Sometimes it is better to step away from the code for a bit and come back later with fresh eyes on the situation. It usually helps me find what I need to find so I can move on.

--

--