@Xilef: What's wrong with flat inheritance trees? Composition over inheritance is good practice. I rarely use inheritance anyway except for abstract classes for groups of closely related things, and Unity presents no problems with this.
IMO the most significant problem with Unity's architecture is that it's difficult to avoid lots of cross-component communication, but that has a lot to do with many things being innately coupled in games in general. I haven't seen many architectures I thought were better.
ZenVirZan":1mgmqyla said:
With 2D, you have a loop, where you run #update on objects. These objects can access other objects by ID. In Unity, you attach a class object to another object and what??? call it by tag??? idk how am i meant to use this stuff
You do this in Unity too. Every component has an update method, and you access other components by type. Entity-component architecture is supposed to let you define an entity by combining components in lots of ways to define behavior. For example, a fireball projectile might have a glowing component, a VFX on hit component, a play sound effect on hit component, a homing component, a projectile component, etc. Then you can easily make similar related things by attaching components in a slightly different way, like a gun bullet might have the same components but not have homing behavior and instead have some kind of hit on contact behavior. Think of components as like a list of behaviors or properties that describe the object they're attached to. It takes a little bit of practice to wrap your head around it, but it's pretty good once you understand it.
also if i have an enemy class why do i attach the same script to all of the instances? it feels like its mixing up instances and definitions
i guess i just need to looks at more tutorials or something idk but i dont like it
Like Xilef said, you make a prefab with your enemy script(s) attached and spawn instances of the prefab. A prefab is an entity with preconfigured components attached, so you can think of it as the "definition" for one entity. Again, components are like a list of properties you attach to entities and are designed to be reusable.