Welcome to gamedevs

Week 8

This week we had made a class diagram.

Now instead of explaining why Unity is a special snowflake, our friendly neigbours over at Wizards vs. Robots wrote a great blog about Unity and it’s style of composition over inheritance: https://4kills.wordpress.com/2021/11/16/what-a-rider/

TL;DR: Unity doesn’t really fall under the rules of OOP and avoids inheritance. It handles most of its logic in seperated scripts that can be added to objects (therefore composition/ made from diffrent scripts).

Class Diagram

Now to explain this great hydra: Any Entity (Game Object) within the game is made up of different components most of which are provided from Unity like Transform(Positions and Rotation etc.).

One of those components are the scripts that we as developers write. Depending on what scripts the object uses, it’s purpose will be different. For example an interactable object could be a door or a damageable, artifical controlled object could be an enemy or npc. This allows for mix and matching from different scripts.

It is to mention that the implementations of the interfaces needn’t be universal and there can (and will) be various implementations for a variety of entities.

Personally, I like this composition approach in Unity. My biggest gripe with Unity is that not everything is handled within code. I like my things to be where they are relevant and easy to track down. But Unity is more oriented on editing properties with its UI. But I guess I’m biased (not based) since I dislike the mouse and use VIM.