I was lacking some knowledge about the interfaces in C#, so my teacher gave me a project to help me.
He asked me to make a few NPCs that will move randomly in an area, with each NPC having it's own interactions with objects or other NPCs.
If you want to look at my work you can go to my GitHub repository.
                                  ​​​​​​​​​​​​​​
I first started to make an area for the NPCs to walk around in. Using ProBuilder I made a quick area with walls, a tunnel, and a higher area.
Then I used Unity's NavMesh system and started to make my NPC move around by picking a random point in an area around itself on the NavMesh.
I've made a total of 5 NPCs, and 3 different objects.
There is a NPC component native to every NPC behaviour that allow them to find a point on the NavMesh, change their destination, and animate their bodies.
Then each NPC has a different behaviour with the NPC behaviour inherited.
For each behaviour they roughly do the same things, find an object or NPC they can interact with, go near them and interact with them.
Now for the objects, this is where I used the interfaces. Each object has one or two interfaces linked to them.
 - The ball has IKickable
 - The soda can has IKickable and IPickable
 - The chair has ISeatable
With thoses I can easily decide what any object can do. If I want to add an object that can be kicked, picked up, and sat on I only need to create the object with it's own behaviour and the correct interfaces. The NPCs will interact (if I did my safety checks properly) without any problems or without having to add anything.
                                  ​​​​​​​​​​​​​​
Now that I have a base with random behaviours, I will work with the animations of each NPC.
As you can see on the gif, the animations are just thrown on the NPCs. They are not smooth in their transitions and I plan to make it better.
I also plan to make some IK interactions like having the NPC that picks up the soda can has their fingers wrapped around it, or the arms of the NPCs that adapt to the walls if they are too close, and other stuff like that.
Back to Top