Friday, May 26, 2017

7 - More waypoints!

Actually no. No more waypoints. Just a surefire way of making a network of them! So yesterday I was feeling very bogged down with homework and assignments, so I decided that I would not work on them to feel better. Instead, I booted up one of my old waypoint AI maps I haven't (have not) worked on in a good while and started coding up an idea I came up with while getting ready for church Sunday morning.

When I was actively working on my waypoint generating program and trying to figure out a good way to connect waypoints such that an AI character can actually walk between them, my brother half-jokingly told me to create an AI character for every single possible waypoint connection and see if the AI can physically walk to it, and it if can, then mark it as a path. Instead, I tried using raycasting (that's just a local term for making rays and shooting them in a certain direction in the 3D world and seeing what they hit and how far away it hit from it's origin) to measure out exactly what was happening in the world: a ray for checking if two waypoints are next to each other without a walk between them, several rays to check if a waypoint if below a cliff from another waypoint, many rays to check if a waypoint was up a ramp from another waypoint, rays to check if a waypoint was up a ladder from another waypoint, and so on. The script became painfully long and hard to understand when looking back at it now, so I decided that the best way to ensure that the waypoint would work is to literally take up what my brother said, execpt tweak it a bit for time efficiency.

If I were to actually test if an AI can walk between every possible waypoint combination, one at a time, that would literally take weeks, even months to calculate. Soooo not worth it. A bit aspect of programming is runtime. Gotta keep it low, we Engineers and computer scientists hate waiting on technology. So I decided to make variables to allow me to change just how far a particular waypoint will look around itself to see other waypoints and how long it will give the AI to try and make it to the other waypoint (allowing extra time for climbing ladders, etc.) Then I set up  method for running many threads - or lines of code - at the same time, so that the process happens by no means one at a time, but rather there will be hundreds of AIs throughout the map trying different routes at the same time. Of course, this could cause collision issues, which I dealt with by having the AIs jump around to avoid each other.

I haven't quite finished coding it up yet (I had to get back to my homework,) but I believe this will be quite a successful attempt and will being me lots of excitement in its (not it is) success.

No comments:

Post a Comment

21 - Personal Narrative

A Lot to Do with Not a Lot of Time             The day was not one of my greatest . Lawn mowers running, hot, humid air, mosquitoes, a la...