Hey Folks,
So another week, and we’re going to dive further into the Monster AI and see how it was expanded and solidified to ensure a more realistic and engaging behaviour pattern.
I discovered during early testing sessions that the monster would use any path it deemed available to get to the player once it had caught sight of them, and this often led to it becoming stuck when it attempted to reach the upper floors of the house by climbing through the window. I also wanted to monster to have a limited duration it could stay within the house to ensure the player would have time to explore after successfully evading the creature, and this meant working out a way to limit what areas the NMA (Nav Mesh Agent) could travel to.
I successfully limited the NMA’s movement using Binary values to dictate which Nav Mesh Areas the monster could choose for its waypoint, creating a movement loop that could only progress when the chosen point was not on one of the forbidden meshes. Having never used binary this solution required research and time to apply correctly, but was extremely effective at helping to manage the creatures movements, simply listing the building and roof, which was made accessible through off-mesh links that allowed the NMA to jump as different Nav Mesh Areas that could then be excluded.
The NMA binary enhancement was then supplemented with the addition of a ‘hunt timer’ that was activated whenever the monster entered the house, with a random range of 2-3 minutes. Whilst the monster is inside the countdown timer activates, with the value increased if the monster encountered the player. If the counter hit 0 then the creature would be forced to leave the house and be unable to use nav waypoints inside the building for a set amount of time, with the exception of specific events, or if it encountered the player.
As the creature had to be able to enter the house, and is supposed to have a basic level of intelligence, the next step was to give it the ability to open doors. This was done by mimicking the way the player interacted with the doors, creating a Raycast from the creature that could detect if a door was in front of it, and then subsequently open it if was blocking the monster’s path.
Initially, with the first humanoid creature, I created a system using Inverse Kinematics that would allow the limbs to specifically target the door handle depending on what side of the door it was on, physically interacting and turning it to open the door the creature would then pass through. This was then embedded into a coroutine where the creature would stop, perform the animation, and then continue through the door once the door had opened. The inverse kinematic method was complicated but visually effective as it made the creature interact directly with the world. It was disappointing that following the change in monster model that this was no longer possible.
Whilst this method of opening doors worked fine in the early versions of the game, as doors became more complex with the addition of locks, this system required expansion and diversification. Initially my idea was to apply Nav Mesh Obstacles to each door and have them turn on when the door was locked, thereby excluding the doorway as a path the monster could take. The problem with this was that the creature would then never try to navigate to that area or go anywhere near the door, since it did not recognise it as a viable path, and so the player could not only seal the monster completely out of the house, but also lock it into rooms.
And that’s where we’ll leave it for this week, so tune in next time for how the Monster ended up handling doors!
Until then,
Nick
If you want to come discuss the game, have a general chat, or reminisce about Captive Audience, why not join our discord or Facebook pages, or follow us on twitter for more news!
Discord: https://discord.gg/bhgXgH
Facebook: https://www.facebook.com/ItWillFindYou/
Twitter: https://twitter.com/HeraldofLoco
0 comments