might as well compile a list of why i haven’t posted anything in over a month
1) finals/final projects (now over)
2) job hunting, 20 resumes sent out every few days. holy shit job market, why?
3) the remodeling of my house
4) building and configuring brand new PC (it cost a grand in parts, and it blows my old system out of the water by orders of magnitude)
but i did manage to make some baller AI. they’ll follow you around corners, but obey line of sight and stop chasing if they can’t see you anymore. i’ll upload a video in a little while.
not dead just busy (tm)
Better follow code, just about done
i fixed a lot of weird bugs with the villager’s movement system, they now properly follow you around when you get close enough, and then go back to their spawn point and wander around when they stray too far.
the last bit is adding little triggers so villagers either wait or loiter when reaching their targets. this is so events passed from completely separate functions can dynamically make the villager either
1) wait and stare (at the target)
2) stop and wander around (the target)
once it’s given something to run towards. the villager will usually wait and stare at a player like in animal crossing, but wander around when it runs towards a structure like its own house.
there are still one big problem though; It only “looks” for the player after it’s successfully reached a new nav node. this means there’s often a delay between getting near the villager and the villager actually starting to chase you. This is a consequence of how the navigation system works at a fundamental level, since it’s based on a little navigation sample included with Shiva, and doesn’t actually move towards something until it’s successfully moved to a new node.
Later on once i revisit pathing, i’ll base the navigation on The Hunt, a little zombie game sample that has active pathing per-frame so the villager’s “lag time” will be zero. It’s much more complex and convoluted (like dynamically enabling or disabling nodes along its path, some ray-tracing, self-checking..) but has more natural behaviors.
but for now i’m turning my attention back to “that damn Sun Cycle”(TM) problem. looks like it’s trig time..
I’M NOT DEAD
this is the result of some additional labor in the navigation system. i basically just took a huge navigation code example, then broke down each line and added comments. it makes much more sense now but it’s still a little weird, specifically how the navigation system really works with nav targets and the distinctions between nodes. i’m not 100% what is being automatically handled, or explicitly defined.
anyway, above is a simple little diddly. the villager will follow me if i get close enough, but otherwise go back to their house and just wander around.
i’m focusing on using the state system to switch between complex behaviors, and further abstract stuff, which will make the crazy event scripting later on (like holiday events) much easier to code, as i’ll just be calling states instead of explicitly making huge switch statements.
Fucking navmesh, how does it work?
for all i praise Shiva, it’s navigation toolset is very difficult to wrap one’s head around. This is made all the worse by there being absolutely no tutorials, videos, or wiki articles describing it in any detail. the forum posts are sparse as well. The documentation is a series of one-sentence descriptors for functions with no elaboration beyond that.
the only thing i really have to go on is the code from this demo game that came with the shiva engine, called “the hunt”. it’s some generic little zombie shooter, but it shows off a couple key shiva things (like the nav mesh).
I’m going to spend tomorrow cracking this bastard open. I’d be happy if i could simply set up a “look at player when in range, pause, run towards player until within a certain range, then stop and look at the player” behavior.
actually i’d be happy with “chase after player when player is in range”, since a chase behavior is like, one of the most fundamental AI behaviors.
WILL THERE BE DIAMOND DOGS
most likely. They’ll probably be part of the random villager rotation, and i might throw in some special stuff if all three of them are in town (like random holes opening up)
Fixed the flicker FOR REAL, sun solution?
turns out the flicker was due to a hasty prototyping decision way early on. I originally had the ground set as a very thinly squashed cube with a Collider attribute attached. This is great and all, but light going through this flat cube behaves very strangely. it’s like putting water between two pieces of glass and squishing, it flows all over the place in strange, unpredictable patterns.
i just make a Y+ normal plane (that means it renders straight “up” in the game world, but is invisible when looking at it from the bottom), and put the grass texture+a collider on it. boom. It actually looks really nice around sundown now, great shadow play
but remember that sun problem i had? read more for a possible solution.
Fixed the flicker, another problem
turns out the flickering was due to the light source being “too perfect”. it would only bug out at 15 degree increment angles, which is curiously the increments i was using for each hour in the day (360/24=15). just adding 2 degrees to the rotation fixes it, and the difference isn’t even perceivable to the player. days and nights work correctly now yay!
but here’s where things get really mind-bending.
Ahn~ My villagers are moving on their own!
so yeah. navigation controllers are a little weird, but not unmanageable. the villagers (the main six as spheres for now) just patrol around outside their houses. i have yet to figure out how to restrict their total volume of movement though, so over time they just randomly wander over the entire map
-put in the hourly music system(animal crossing’s world theme changes every hour. the music track changeovers are kind of stop-and-go though)
-put in some models donated by hoppip
-tweaked a lot of materials and textures to accept and project shadows correctly. it’s not perfect but i’m not an art assets guy. GOOD ENUF I SAY
-made the sun rotate according to the time of day (but doing so introduced a strange light flickering bug, not sure what the deal is.)
-streamlined the player movement system, it’s based on values pushed by events rather than booleans. it’s much more efficient and makes sure that if you try to go left AND right, the values cancel to 0 and you stay in place.
-and as previously mentioned, put in a simple villager patrol script. But, they don’t interact with the player at all (that’s coming up soon though)
so yeah, i am excite
edit: i fixed the hourly music skipping issue. i had used fractional values to fade tracks in and out, and for some reason shiva doesn’t like that. setting track fade to 0 works better