Week 3 - Giving Shelter & Characters Led Astray
A Home For All
Last week, there was a start on natural character spawning inside city buildings. This spawning was on a time-based cycle, where after a defined period of time a character was spawned inside each building with a PotentialHomeComponent. However, this seemed very unorganized, since characters would have no attachment to the buildings that they came from.
This week, that approach was switched out in favour of a 'shelter' based approach. Each building's home component is defined with the number of characters that can spawn inside of it, ranging from 1-5. When characters are spawned inside of buildings, this component also contains references to the characters that it contains. On each spawn check, characters will not spawn if the building already contains the maximum number of characters. This results in each building having a defined set of residents:
With every character now having a hard reference to their spawn building/home, this opens up the door for behaviors based on this home building, such as returning to this building for rest or at night.
Gooeys gone a(stray)
In the process of spawning different characters, an oddity has been discovered in the vital 'stray' behavior tree used frequently in the gooey characters. Normally, the stray behavior is intended to be a simple three step process:
- Choose a random location away from the character.
- Travel to this location.
- Pause for three seconds and repeat.
With one character, this character worked exactly as intended. With more characters however, this behavior becomes erratic, demonstrated using the deer character from Terasology/WildAnimals:
When each deer character picks a random location away from itself, it seems that every other character also picks their own location. With one character this isn't noticable, but with more and more characters this behavior becomes more and more erratic, with each character updating every other character. This becomes a serious problem when you are dealing with the number of characters that are present in a city!
This bug reveals a potential bigger problem that I will need to watch out for throughout the remainder of the project. One of the most important properties of these characters is that they do not influence each other; they act independantly of what all other characters are doing. This bug demonstrates that in some cases, characters could be 'linked' to each other by accident, which could spell issues for more complex behaviors.
It's just about time
One more minor development this week; work on time-sensitive behaviors has begun. These behaviors can include town meetings at specific times, returning home at night, and many more! A pull request was created which adds the TimeSensitiveComponent, allowing behaviors to access time information inside behavior trees.
Over this next week
- Development and completion of time-sensitive behaviors, with a focus on characters returning to their spawn home.
- An investigation/fix for the 'stray' issue
- Inter-character interactions within the city