Posted July 10, 2022 by postosaurus
#2d #glowworm #ai #behavior #plattformer #collectible #first game #first steps #platformer #unity #light #dark
Hello everyone,
after the shadermess has been settled I refactored my project a bit to have a clean point from which I can go on. Now I want to tackle NPC movement and AI's. I have the idea to create NPC that can follow the player. A task could be to bring these home or in a safe space. They will only follow when they are in reach, so the player can lose control over them if she is not close enough.
I thought could be a nice idea to collect something in the game that makes the circle of light bigger, so Fiona can see better. In the beginning I was thinking about a torch that the player could manipulate to see the world around, but I dropped that approach in sake of the new shader and regarding how much headaches I had by figuring out how to get my old FOV-Scripts well integrated into the other systems and make a fun game-play out of it.
So the collectable should not be a battery or torch anymore but rather something organic. I came up with the idea to create glowworms that fly around on the map. So I created a yellow square and tried to give it some behavior. There are some very different behaviors I could figure out and the most interesting ones seemed to be "mistakes" in the first place.
This range of "following patterns" I am already very happy, I think with these three I can already do some game-play stuff. I found one behavior for following, one for gathering in one spot and one for getting attracted to a target but also with the ability to lose interest and to back to strolling along.
So with this I imagine how the player needs to collect glowworms to get a bigger light-circle. Maybe some stick to the player and follow him, others will be easily distracted and the player needs to maneuver them around to solve his task. When the glowworms are in reach of their final destination they can gather on that spot and maybe disappear or float around the object, illumination the scene.
In the search for the "following-patterns" I ran into lots of mistakes in my calculation and found some buggy, yet interesting behavior. I would call this the "flee-patterns", because yeah as the name says it already, the glowworm are fleeing from the target instead of following. I decided to keep all that "buggy code" and now I am happy I did, so I won't go back to define some fleeing behavior by purpose and maybe look on the wrong spot. Implementing the follow patterns already provided me with the flee pattern.
So here is what it looks like: