So my friend and I are working together to make a game. We wanted to add an enemy that will chase people even with the doors closed. We knew how we can implement this feature, but we did run into some problems. When the NPC was pathfinding, it was very jittery. It would slowly and jitteringly move from waypoint to waypoint since we were constantly computing the path and stuff. We came up with the idea of only making the enemy move to waypoints that were going to change the direction of where the waypoints lead them. We knew we could just compare the angles of the waypoints to see if we can skip it or not, but that’s where problems began to occur. It decided not to work and when I started debugging, it showed that the current direction is what we want but the previous direction is just Vector3.new(-nan(ind), -nan(ind), -nan(ind))
. After some confusion, I later found out that -nan(ind)
just mean undefined. This happens to stuff like when you divide 0 by 0. However all I did to the previous direction was set it to the current direction if the current direction was the same as the previous direction. The previous direction should just be a look vector and I should be comparing a look vector to a look vector. However, it just shows that I’m comparing a look vector to an undefined vector which I have no idea why that’s happening. Do any of you have any idea of what’s going on here?
It would help with debugging if you showed the code!
1 Like
i did some debugging where it printed the current look vector and the previous look vector. The current look vector was normal but the previous changed to undefined
i just figured out the problem. I put the waypoints in a for loop starting at the last waypoint before an angle changes. I was supposed to do after the waypoint instead of with it so I attempted to make a CFrame where the position was that waypoint and the lookAt was the same object