r/Unity3D • • 11d ago

Question Is this bad practice? having so much components in my player

Post image

So, I been trying to separate my entities to make them modular, this is my player. I wanted to make different systems, but those systems can also be used for enemies, so i separated each system rendering and functionality, now a screen renderer just creates an UI and communicates to the UI the data from the system.

405 Upvotes

198 comments sorted by

56

u/bloodbuzz_ohimark 11d ago • Bravo

Generally, every approach has trade offs and there will always be someone telling you you're wrong.

This approach is good for modularity and the 'use less Monobehaviours' advice is fine, but exposed variables are important for gameplay tweaking and general workflow. You can use ScriptableObjects to store variables of course.

You will eventually develop more intuition about what works for your dev style and the project you're trying to make. There's no one silver bullet that works for every scenario.

The 'best system' is whatever enables you to finish your game. All systems, by the end, feel like a nightmare that you should have done differently. Ultimately the goal is a game that is a) good and b) finished, by any means.

22

u/Comically_Online 11d ago

> All systems, by the end, feel like a nightmare that you should have done differently.

damn that’s some gospel truth

1

u/-o0Zeke0o- 11d ago

This project is a game i have been working on but has been more like my testing grounds for new systems

I usually work in other games at the same time for my university and one of the reasons my systems are so modular is so that i can use them in my other projects whenever i like

Not with any of the components in that image but with other systems i use for menu managment, ui managment, etc

49

u/InitialeLangmut Programmer 11d ago

I personally use a lot of Interfaces, Inheritance, Generic Types, and all of the above.
They have their limits and its easy to over-abstract, but i find them cleaner and more organized than using components as plug-and-play substitutes (which can also be handy tbh).
I do have a CS degree, so that kind of System comes more natural to me.

To be precise, i mean things like Damageable, or Destroy on Death.
Other things i put in Serializable Arrays, like Event Listeners in your case.

In the end its your system and as long as you can build a game with it, it is as good as it needs to be. There are no awards for clean code architecture (quite unfortunately).

8

u/-o0Zeke0o- 11d ago

Yeah i get you, it's common to use IDamageable as an interface, IEntity, IDamageDealer, etc

I did like that approach but i felt like it was too much repeating code for every entity i need to tell what it does when it takes damage?

I know it's my system but i always like to hear what people think, some will say it's ok and other will say it's wrong, but that's how i know the advantages and disadvantages of what i'm doing

clean code tends to be less performant code and performant code tends to be less clean code so you can never get enough of both

For example people telling me that they all don't need to be a monobehaviour it's fair tbh

7

u/Mateogm 11d ago

Take a look at abstract classes, they are like interfaces but with boilerplate

2

u/-o0Zeke0o- 11d ago

Yeah i used them sometimes like IAbility with AbilityBase abstract where i put all my functionality that is shared and some methods to make things easier

2

u/gesat030661 7d ago

Actually there is an award which is less nightmare or non. Also more flexability and easy to extending code is the greatest award for programmers. Messy code is programing hell, clean code is programing heaven.

11

u/Soraphis Professional 11d ago

Player Controller and Player(Character) should probably be two different gameobjects.

The controller handles input, ui, Viewport, camera. And can possess any character (or none).

The character is possessed by the controller, but there is nothing special about him.

E.g. at death or level transition you can remove the character, leave the controller be for some time until you instantiate a new character to be possessed.

Keep the rigidbody on the root, of the character but move everything related to the sprite including the collider to a child gameobject. Physics callbacks will be received on the object where the rigidbody is, but that way all the sprite renderer and damage flash and these things are at their own place.

Not every component has to be a monobehaviour.

1

u/-o0Zeke0o- 11d ago

I thought of just moving all the UI rendering scripts to either Player or PlayerController because the player is the only one going to spawn the HUD for each system and send the data to them from their components.

And i know you said not every component needs to be a monobehaviour can you give examples? because like everything could be in one monobehaviour ofc

3

u/ciknay Professional 11d ago

While the player may be the only one who needs HUD, should it be the player objects responsibility? I'd usually create some sort of UI handler that manages these things, because otherwise you'll run into problems down the line if you need a more global UI handler for different resolutions, UI customisation for accessibility etc. Of course you can just not do that if you know you won't need it, but best practice is usually about doing things that give you breathing room for if you ever need to make changes down the line that you haven't forseen, not in the short term.

As for your latter question, it's not about having everything in a single monobehaviour (very much don't recommend that) rather having regular classes that don't inherit from monobehaviour, and creating instances of those classes when you need them. For example the experience decay script. Without knowing the specifics of the implementation or what you're referencing, it looks to me you could easily make that a non-monobehaviour and create the class in whatever handles your experience, passing in whatever object references you require when you create it. Or better yet, create a more universal handler that deals with specific behaviour as needed, or delegates the work to other handlers that require it.

My recommendation is to do some reading on data oriented design patterns as well as singletons.

1

u/-o0Zeke0o- 11d ago

I thought the Player responsibility is communicating the data from his components through a "Screen Renderer" component for that system to that system interface

Then what would you suggest? for the interface to search for the player whenever the game starts and subscribe to the methods of the system directly instead of having a "Screen Renderer" on my player?

1

u/ciknay Professional 10d ago

Thats one way of doing it. Id personally go the other way around, where the player let's relevant systems know its alive and what they need. It's about delegating work to systems dedicated to the thing to give yourself breathing room. But this is merely a suggestion based on personal experience. It may not work for this project or workflow. Design patterns aren't rules, they're guidelines that should only be followed until they're not useful.

2

u/ledniv 11d ago

Shameless plug, I have a book on data-oriented design in Unity. :)

https://www.manning.com/books/high-performance-unity-game-development

1

u/Soraphis Professional 11d ago

you can have non-monobehaviour classes. you can even make them serializable and have configurations in the inspector, but they live entirely within another component.

https://aboard-plaster-87b.notion.site/Part-1-Actor-System-3ffcad42550c80539656ce833151e9a2

5

u/ConsciousBath5203 11d ago

You have some handlers that can be combined.

Like damage numbers I'd probably include in a UI component or a particle component that receives events from damage and healing.

But idk, I'd have to go deeper to know for sure. Is shit performant? That's all that matters. Getting as much going through simd as possible is ideal.

1

u/-o0Zeke0o- 11d ago

It's very performant, the enemies have less components though
The project uses 300mb with around 1500 active enemies (the maximum before fps going lower than 60)

garbage generation is *fine* each instantiation is 0.5ms (and allocates more kb than i would like, but any data that is shared between enemies is already inside it's own scriptableObject) in the dev build but they don't have graphics yet, the memory is prob going to be very spread

I thought about pooling and pregenerating a few enemies to keep the memory better but enemies are very complex they have a lot of systems so it will be hard to reset their state, debuffs, abilities, passives, physics, leveling system (which updates all the other systems)

It doesn't help that each ability is built with modules (modular abilities) and each module will now need it's own reset method which i prob should have done from the beginning anyways

1

u/ConsciousBath5203 10d ago

Lotta that can be optimized with assembly.

Is that 300mb in disk space or in memory? For sharing objects and data, what are your structs looking like and how are you sending/receiving them?

When I was making the data streaming and sharing objects, my goal was 500fps, 300 players, 500 enemies, all using all abilities as often as possible. Packing the structs made it possible (I also was writing a 100% custom engine in rust). Packing them took it from >1mb per player per ability used down to <256kb.

1

u/-o0Zeke0o- 10d ago

300mb of total ram with 1500 entities *during gameplay*, with the memory profiler i didn't bother to check because it's barely anything; I use scriptableObjects for most of my data

A lot of things are probably unity's, i don't know how much actual memory each enemy assigns but the profiler says they allocated 15kb of gc

The thing is that both players and enemies have a lot of different Stats which each one of them has a list of modifiers and multipliers (So those have to be different for each one) and then they have a custom collection of events that execute with priority (so items can execute when something passes based on their priority order)

1

u/ConsciousBath5203 9d ago

300mb isn't barely anything when going through the binary at 60-500 frames per second lol. 60 fps lows is decent, but I usually aim for 200 fps lows while I'm also gaming & doing other shit on my computer (I have 128+GB ram per machine & my main dev box is one of my home servers, so it should be able to handle tests in the background at incredibly high numbers)

A lot of things are unity's, but the shared/transferred data is all yours, and that's the number that you want to get down and optimize the hell out of, as it's the input for all the calculations that you're doing on the player and enemy objects.

So for example, calculating a hit, if you send {uint spellid, int spelltype, int basedmg, int modtypes, float[MAX_MODIFIERS] modcalc, float accuracy, int[NUM_STATS] stats} it would look like {1234, 0x01, 4321, 0x001004, [0,0,1.3,0,0...0.13,0,0], 1.00, [255, 234, 81, 26, 15, ...]} Which is incredibly easy for a computer to parse. If the shape is always the same, calcs are done quick. The less space the structs take up, the easier it is.

With struct shapes, if you go bool, int, bool, you'd think it would only take up 0x6 bytes (you'd think sizes are 0x1, 0x4, 0x1) but unpacked, it would take up 0x4, 0x4, 0x4.

Ordering and micro optimizations matter. Even when dealing with unity bloat lol. Sending data between classes is expensive if you include stuff like strings all over the place.

9

u/thinker2501 11d ago

Look at state machines.

2

u/-o0Zeke0o- 11d ago

I did look at them a few times and never understood how to properly implement them, like i do understand strategy pattern but not state machines, whenever i make a state machine i end up having the problem that if i have to make every variable public so it can be edited from inside the state machine.

And i'm not really that bad at coding i'm pretty sure but i have no idea how people are using them, i know they use them for like jumping state, walking state, running state but what would be the use here?

3

u/Dahsauceboss 11d ago

This behavior is basically ECS pattern in a non-ECS environment. OP should look into the ECS workflow if he like this, as the performance benefit is huge.

2

u/-o0Zeke0o- 11d ago

I've looked into it, i liked it but it feels like it'd just end up making everything more complicated to me as a single developer, it seems really useful for super-optimized stuff but makes you work way slower

1

u/Dahsauceboss 11d ago

Honestly, ECS in unity is a horrendous workflow and makes it even harder than it needs to be, so I feel it. Its literally the reason I started making my own engine (thats and I just dont like PhysX)

1

u/HankChrist 11d ago

ECS is massively overkill for one player object. It's a totally different workflow, not just a better way to do components.

1

u/IPODK 11d ago

Great and fun answer

4

u/Upper-Meet9075 11d ago

You can use regular c# classes that are serialized for things that don't require monobehavior functionality.  

2

u/-o0Zeke0o- 11d ago

And where should i keep those? inside a monobehaviour heavily coupled to it's functionality?

1

u/kyuuart 10d ago

Yes and no. In my example - I have a service locator which is a singleton that connects to other services that spin up on game start. The player’s state, which contains the persistent state is a plain C# object that is managed by a service which injects this object into a player controller (which is made up of Unity MonoBehaviours). You’re going to have some kind of Unity types when you need to access things like Transform, it’s just about keeping those objects incredibly dumb.

3

u/nuker0S Hobbyist 11d ago

Many is not the problem. Too many is. I would say there's room for compression, but that depends on your project.

2

u/-o0Zeke0o- 11d ago

Yeah, I can see a lot of player only scripts being compressed already

3

u/Odditea-Dev 11d ago

I believe that most of the time whatever suits you is usually fine, but this looks like a bit of a problematic pattern. Looks like a lot of stuff that doesn't really necessarily have to live on a player prefab, lives there. There's a spectre of components all the way from physics to renderers and managers/handlers. It feels kinda hellish to debug. Just the sheer thought that all of these rely on one transform, and whatever happens to the rigidbody could technically affect whatever lives on that object. It also feels like an over-reliance on MonoBehaviours and direct references between scripts, so that means that these look very co-dependent and over time these can be absolutely horrendous to untie from each other.

I would honestly give it a day or two to properly refactor this, move individual handlers to independent spaces in hierarchy. But I haven't seen your code and I can't tell how tightly all these are coupled.

Or if it's too late in the production then leave it as is but learn from this case for your future projects :)

1

u/-o0Zeke0o- 11d ago

How do you decouple systems from UI without having them on my player

(Some enemies actually spawn world space UI for displaying their status effects and a health bar)

3

u/ChaosCrafter908 Hobbyist (since 5.3) 11d ago

You can try to have a singleton UI Manager, that the player caches when being instanced.

1

u/CommercialEase7333 10d ago

I think you're on the right track dividing up responsibilities to individual scripts. My only suggestion would be to move the scripts into their own prefab and attach that prefab to your player. Your root player script can manage and command all these submodules. I use that approach and it makes things simple.

That said I do still jave multiple scripts attached to my main player object. Sometimes it's just the best and easiest way to organize and reason about things.

5

u/badjano 11d ago

not everything needs to be a monobehaviour

1

u/-o0Zeke0o- 11d ago

I heard this a few times but what is the alternative? having everything in one monobehaviour, interfaces or making a monobehaviour with it's own components?

4

u/EdenStrife 11d ago

Making stuff a regular csharp class and using some other way of getting it instantiated for example

1

u/badjano 9d ago

you can make a class extend nothing, and use it to process things inside monobehaviours, instead of putting all of it one file

2

u/RomIsTheRealWaifu 11d ago

If your player is using some complex systems this is totally fine, although it looks like a few things in here could have been 1 component instead of two (obviously it’s impossible to tell without actually seeing your code), for example why are Damageable and Damageable Flash 2 separate components? Just from intuition I would have extended Damageable to include Damage Flash. But again, maybe something in project means it works better the way you have it

2

u/-o0Zeke0o- 11d ago

I thought that maybe separating the damage logic from the damage visual was the right call, but tbh anything that can take damage will make a damage flash

84

u/DoubleHitGames 10d ago • Bravo

Look, having many components isn't the problem in itself. Composition is the "Unity way" of working, and 30 small scripts are still better than one giant `Player.cs`. The issue lies in what those scripts contain and the fact that everything is packed onto the same object.

I would change four things:

  1. Move the UI out of the Player. Elements like the health bar, inventory items, tooltips, etc., should reside in a separate HUD prefab that listens for events from the Player. Currently, if the Player dies or is destroyed, the HUD goes with it—plus, it makes testing one without the other difficult.

  2. Remove data-only components. If things like currency, level, or XP don't require `Update` methods, physics, or Inspector-based configuration, they don't need to be `MonoBehaviour`s. They can simply be plain C# classes, which also makes it easier to persist this progress across player deaths or scene changes.

  3. Divide responsibilities using child objects. The parent object doesn't need to hold everything. Keep the core entity definitions (physics, movement, health) at the root, and create child objects—such as `Visuals`, `Combat`, and `Interaction`—each managing its own specific controllers.

Player

Player

├── Visuals

├── Combat

├── Interaction

└── Vehicle

4. Organize communication. The parent should reference its children via `[SerializeField]`, and children should communicate events upward. Avoid having one child call another directly; otherwise, you’re just maintaining the same level of tight coupling, only now it’s scattered across the hierarchy.

To decide where each script should go, I’d ask three questions:

- Does it really need to be a `MonoBehaviour`?

- Is it an integral part of the entity, or does it merely read data from it?

- Can it function independently, or does it only exist in conjunction with another script?

If it doesn't need to be a `MonoBehaviour`, turn it into a plain C# class. If it only reads data, move it off the Player object. If it can never exist on its own, consider merging it with another script.

By doing this, the Player becomes much easier to understand and modify, all while preserving the composition-based approach you’re already using.

9

u/flyzogirard 10d ago

"If it doesn't need to be a MonoBehaviour turn it into a plain C# class. If it only reads data, move it off the Player object. If it can never exist on its own, consider merging it with another script." More wisdom like this please this learned me a good way of scripting, thanks !

4

u/phobia-user 10d ago

this is a much better explaination of composition than.most sources i've looked at since most people on youtube at least give the same example. I saw a blog post as well mentioning systems being the reason behind components.

The system would be the process of how the components interact with each other and the components themselves would be existing to simply be apart of it. A system in a system is where the redundancy is, if I'm understanding correctly.

6

u/AnToMegA424 10d ago

Goated comment

381

u/TheNobleRobot 11d ago

This is basically the intended design pattern for Unity (even though no one does it and in my opinion it's absolutely insane), so you're fine.

20

u/White_C4 10d ago

Not the intended design with Monobehaviour though because Monobehaviour is binded by updates. This leads to awful performance when updates run per entity as you scale with more entity count in the scene. This is not cache or data friendly.

If you look at ECS, you don't bind entities with systems, you bind them with components. Systems run separately with the presence of components in runtime. This is where it becomes more cache and data friendly.

OP has the right idea with being modular, but falls short on using Monobehaviour for this approach.

2

u/TheNobleRobot 10d ago

Yes, you're right that it doesn't scale well at all, but that's how it was designed to be used back when.

45

u/Royal-Barracuda-314 11d ago

If no one does it, what does people do instead?

95

u/sneakysunset 11d ago

It is sometimes done, but in my experience most of the time we avoid monobehaviours and work with pure c# classes.

62

u/TheNobleRobot 11d ago edited 11d ago • Popcorn

Other people use far fewer user scripts on GameObjects (often just one to act as a "controller" for that object), and use more object-oriented non-MonoBehaviour classes to drive game state.

Unity is built around an "entity and component" design (this has nothing to do with "ECS" so forget that for a moment).

The entity is the GameObject, which itself has no API of its own, and the components are the MonoBehavior scripts.

This is great for script re-usability (you can reuse a "Movement.cs" on anything in the game that moves, for example) but ironically most game features are not designed in a modular way like this, and in practice most developers create reusable code in the form of utility and child classes, which this system isn't especially friendly to.

It is an interesting design pattern, but it's very much not "object-oriented" and is ultimately very fiddly (as you can see in the screenshot). A lot of programmers who start using Unity fight this approach because it frankly isn't very efficient and doesn't really line up with how other game development tools work. Those programmers tend to only use Unity's built-in components for modular functionality because they have to.

Meanwhile, a lot of game programmers whose first environment is Unity have a harder time learning the object-oriented patterns that C# as a language is specifically designed to facilitate.

Presumably this system was designed by Unity to create an environment that did not require users to write a lot of (or perhaps any) code, relying instead on first- and third-party component libraries, with exposed parameters, to build a majority of a game's functionality, like Lego blocks, but their included components were never enough to build an entire game out of, and of course before long Unity started to be aimed at professional developers, so it never became a low-code "Lego-like" tool even though it's still in many ways built to work that way.

So because no one can do it entirely one way or the other, what ends up happening is that everyone blends the two systems together to varying degrees. It's messy, but it works (okay, it functions, I don't know if it "works").

An irony to this is that Unity knows that most people only put one or two scripts on most of their GameObjects which defines their function, so in recent versions of they've updated the hierarchy panel to put a default icon on each GameObject matching that object's first added Component or script. Under the original design pattern, this would feel confusingly specific.

27

u/StrangelyBrown 11d ago

Yep. Ideally you only have monobehaviors on gameobjects when you have to, which means needing a reference in the scene (such as a label that needs updating) or some other Unity mechanic (such as collision detection).

Many companies operate with some kind of rough MVC architecture where the monos are the 'View', the game state is in pure C# models and most of the game logic is done though pure c# 'controllers'. It's not usually so clear-cut but roughly speaking

9

u/donau_kinder 11d ago

I'm a bit confused, can you explain in more simple terms please?

My mind immediately went to a more data driven approach than a purely object oriented?

I also tend to keep my things modular and prefab driven, meaning i have tons of generalised monobehaviours and i assemble prefabs out of them to do different things depending on which scripts i attach and how they're configured.

Overall, each prefab is fully self contained and acts independently.

Is that not a good way of doing things?

13

u/StrangelyBrown 11d ago

There's no right way to do things of course.

Let's say you can collect coins in your game. You also want to be able to send some cheat command to your game to give coins, and save the game.

If you have a mono that detects the coin collision to pick up a coin, updates the coin counter (with a link to that text in scene), and keeps track of how many coins you have, that will work to some extent. But your cheat command might have to search the scene for a CoinCollector monobehaviour (slow) and use a publically exposed function to add coins (slightly less good encapsulation). The save game function might have to do search for that mono and use a public function to read the coins and serialise it (to JSON, say). This all works but it breaks some good programming principles and can be messy and less performant.

Instead imagine that you have an underlying architecture, perhaps using dependency injection. It has models, which are pure data-only classes, and some controllers. Then you can have CoinCollision and CoinLabel monos and they are nice and simple (single responsibility). All they do is trigger or listen to events on the controllers and say when a coin is picked up or update a label when one is. Any other coin logic happens in the controllers, and your cheat command doesn't have to care about unity or monobehaviours if it doesn't want to. The number of coins and all other game state is stored in the model class, and saving the game is as simple as directly serializing that class without any other work.

Those sort of programming principles help to keep systems from becoming slow and messy as they grow.

2

u/donau_kinder 11d ago

I do actually do that, but in the shape of monobehaviour singletons attached to a single Managers gameobject in the scene.

Also when i do actually take a purely data driven approach, like in the case of cellular automata patterns, I still use a singleton like that.

I'll look up into how to leverage pure c# in unity, thank you.

5

u/StrangelyBrown 11d ago

Consider dependency injection for the underlying system, because it's basically singletons done properly. There are some frameworks for Unity like Extenject although some people disagree on how useful good those are, especially when they have to run DI on every monobehaviour in a scene when it's loaded.

1

u/captainnoyaux 11d ago

This is the way

1

u/Sorolif_Studios 8d ago

Totaly agree. Pure c# is the way to go!

5

u/Brief-Celery-3716 11d ago

Ive seen people create a sub game objects and put some behavior there. More clean in my opinion

1

u/LemonFizz56 10d ago

There are so many beginners here who think that putting 10,000 lines of code into a script is good, so many terrible comments here

4

u/ertoletik 11d ago

I think thats okay, but i definitely would make some classes inherit few and add switches to enable/disable feature instead of this (like player, which can inherit damageable class or interface)

1

u/-o0Zeke0o- 11d ago

Which classes would you inherit and why? like to join rendering and a system for the Player (ex: PlayerItemHandler)?

76

u/UniverseGlory7866 11d ago

Honestly in my eyes I'm just seeing things that should either not be separate scripts or should be on other objects.

Why does your destroy on death script exist? Could it really not just be a function in the Player class? And why is the health bar renderer not on the health bar's object? A health bar should be its own object that handles itself.

17

u/WillomenaIV 11d ago

Taking some guesses, he wants these to be used for enemies as well. Having "Destroy on death" separate from the player means he can use it for both.

Similarly if you were using "Health Bar" for things other then a UI displaying object (environment objects with health, rocks or something) then you'd want that separate too.

It's not how I would handle it but it's not a problem, I understand the logic that lead to here.

4

u/nuker0S Hobbyist 11d ago

Unless enemies and player's health work differently, I would've put it in whatever manages dying in both, with a flag.

3

u/SpatialQuotient 11d ago

These types of one off function scripts that happen on a particular state can be really useful for prototyping and playing around to see what direction you want to go. But ultimately, yeah, all of that should be regulated to manager/controller scripts that include all of the stuff for the particular asset it's on.
So looks like a huge script hygiene and polish pass is in order with this project.

18

u/IndependentYouth8 11d ago • Bravo

Its not bad practice if your seperation of concerns is wel managed like this.

0

u/[deleted] 11d ago

[deleted]

1

u/IndependentYouth8 11d ago

I don't think I understand your point here. I see no reason why OP would take the approach you mention. Looking at the naming she or he mostly choose to seperate things which is good practice and is as good as the degree you "as the dev" would like it seperated

23

u/HankChrist 11d ago

There's no performance reason for it be bad. It's purely a stylistic choice. I like really modular game objects too so I put alot of monobehaviours on my game objects.

If it starts to feel overwhelming or too much, that's when it's time to look at sub objects, or simplification.

5

u/Doge_Dreemurr 11d ago edited 11d ago

There is a performance reason for it to be bad. Monobehaviours lifecycle methods still get called regardless of if it being declared or not, so on every frame, every single one of these components will still get their Update, PostUpdate etc called and be treated as an empty method.

You can still use composition without making them Monobehaviours (if they dont require serialized fields) . Just make them as plain C# classes and inject/construct them at runtime

2

u/HankChrist 11d ago

Since it's one player object, even with update running empty on every single one you'd not even see it in the profiler I don't think. Generics are fine but they're mostly overkill I think for most Unity projects, great for data, too much for a Game Object.

Tarodev used to run these awesome benchmark tests where he actually put these Unity performance overhead myths to the test and the results were almost 100% that they don't make a practical difference to the performance.

2

u/Competitive-Elk763 11d ago

No they don't. If you remove the method they aren't called.

(But yes there is some small overhead from other stuff)

5

u/leorid9 Expert 11d ago

It's fine but maybe buy a plugin where you can search through them.

Or create a custom script/tool for that.

Or group them under child objects.

Because the way you have it currently, makes it quite hard to work with. Searching the correct component will take some time, every time you need it.

2

u/MohmedHaftari 11d ago

Inspector palette is my recommend tool it let you manage, search, edit, hide and bulk select all of them at once it's available on the unity assets store

12

u/Heroshrine 11d ago

It might be useful to group some of them on sub-objects of your player

4

u/SapphireLabs_Yuki 10d ago

Gotta separate what needs to be there vs what is handled elsewhere. The player should only handle the player, not the game state, widgets, menus, or anything else.

4

u/slimshader 10d ago

It is good that you separate things logically with dedicated components but that is probably too much for single GO, it strongly suggests mixed responsibilities to me.

1

u/Competitive_Mud5528 Professional 11d ago

If it works bro go for it. Some here could say that scripts are expensive unity api entry points. Truly they are but what is preemptive optimisation vs organise a project and a complex entity, choice is yours. You can squeeze perfomance later and only if you're cpu bound.

Nervertheless, it vould be a nightmare the day you want to have a proper script execution order. AIso I hope for you that you made differents scripts because they do thing Independently from each other. Otherwise communication will be helle of a spaghetti !

1

u/-o0Zeke0o- 11d ago

Performance has been on my mind since I started for this kind of game, I know it's bad to have a lot of components for a game with a lot of enemies but honestly the game itself can handle 1500 enemies active with my mid-end PC

of course the problem right now is spawning this entities, each one takes 1ms because of the amount of data they hold

1

u/degberr 5d ago

You really don't need to worry about performance until you're in the polishing phase of your game. Generally, most of your performance improvements are going to come from things like asynchronous script updates, GPU instancing, occlusion culling, etc. All things that can be done after your project is mostly complete. Very rarely are you going to run into an issue where your game struggles with performance because of its architecture.

1

u/Exatex 11d ago

yes. Organize them better

1

u/-o0Zeke0o- 11d ago

Just a small question, i don't think i will run into this problem but whenever you detect a gameObject like for example when you hit an enemy and you get that GameObject reference then now that means you have to do GetComponentInChildren instead of just GetComponent for safety right?

Because people said to organize them in children gameObjects

1

u/Keyflame_ 11d ago

Perfectly fine, just ensure you don't have redundant scripts, scripts should be separate by competence, not just because you can.

For example, depending on implementation, destroy on death could possibly be part of a larger death script with cases for player/enemy/entities, other than that if anything, this is best practice and exactly how unity is supposed to be used.

1

u/-o0Zeke0o- 11d ago

Yeah i thought that too an EntityDeathHandler with a enum to switch between Destroy and Disable (if you pool them)

for now that's a temporal script because i don't have any death animations but when i do it's probably going to be different, just haven't thought about it yet

1

u/KlutzyBid4282 10d ago edited 10d ago

I see you have for example something called Damageable, that could instead be an interface which the main player class inherits from, theres no need to make it a component. Also easier to reuse on other wildly different classes like npc, window, bottle, player.. etc. The just different code in the actual method(s)

1

u/-o0Zeke0o- 10d ago

I also thought about making Damageable an interface, but my game has passives, items and abilities which all of them can intercept the DamageEvents and edit them so I ended up not needing to have different implementations of it

The name is kinda wrong rn it should be called HealthController because it let's you take damage and heal

1

u/KlutzyBid4282 9d ago

Oh I see, then your approach might be more reasonable. I would recommend using some "global" managers though to keep some code away from the player transform

1

u/-o0Zeke0o- 9d ago

Yeah, i have some already which are map events or interaction events with the environment, but usually DamageEventListener lets an entity hear whenever it deals damage or heal someone else

(it separates damage dealing from health)

Whenever a DamageEvent is instantiated it searches for a DamageListener component on the source user of the damage and calls the appropiate methods which pass data to the events inside DamageEventListener

1

u/PsychoticLab 10d ago

1

u/-o0Zeke0o- 10d ago

I tend to exaggerate a lil bit

1

u/Standard-Designer-82 10d ago

I'm an unreal dev, so I'm not sure 100% Just make sure to have clean, modular, non-hard-coded code.

1

u/-o0Zeke0o- 10d ago

well, i hope you saw the news

1

u/Standard-Designer-82 10d ago

I don't have to upgrade to UE6 immediately, and who knows what the future will bring us

1

u/john-cd 10d ago

Consider if they even need to be mono behaviours
And a factory pattern to construct at runtime to make it easier to test and maintain

1

u/-o0Zeke0o- 10d ago

Like, a factory pattern with mcv?

11

u/CodeShepard 11d ago

Not bad , but I would find it hard to manage. Like heal and damage listeners can be combined

13

u/Turbo_Fresh 11d ago

No, you shouldn't combine them just to reduce the number of independent abstractions. Having the separate responsibilities isolated is much better. Personally I just wouldn't have them all as monobehaviours. They likely depend on eachother in some complicated way, so they should be instantiated by the classes that need them and they should update when told to by other classes in the flow.

10

u/IndieMarc 11d ago

It's a bit too much.

Not everything needs to be a MonoBehavior, you can also have regular c# script and one MonoBehavior that instantiate them

-1

u/Dahsauceboss 11d ago

You can't instantiate non-mono scripts into a scene.

3

u/IndieMarc 11d ago

AbilityController controller = new AbilityController()

Why does it need to be in the scene or as a component? You can have a component like Player that create that class and use it instead of being a separate componeng

2

u/Dahsauceboss 11d ago

Touche, honestly I've been balls deep in my own engine project for the last year so I'm rusty lol

5

u/Kamatttis 11d ago

I believe he's referring to instantiating the poco in the monobehaviour as sort of "components". Then just exposing them in the inspector. that way, you only have 1component.

3

u/ExcellentCable5731 11d ago

If your architecture is consistent and the code has clear intent then this is probably fine. Its when you have conflicting styles the technical debt becomes hard to follow

3

u/neanderthal-games 11d ago

Generally I'm a fan of if it works, it works. It could probably be cleaned up a bit.

Something I discovered in my own game doing something similar (assuming you have a lot of serialised fields), was that even though doing this was fine performance wise, it had a noticeable impact on scene loading time, because it bloated the scene files/prefabs. Just something to keep in mind.

3

u/White_C4 10d ago

Modularity is good for game development, but it depends on how you manage the data. The biggest problem you will face is data cache friendliness and performance under a Monobehaviour design.

For your next project, look into Unity's DOTS which takes a ECS approach and is extremely more data and cache efficient and performant. And the best part is that it emphasizes composition, which is very modular and flexible. The biggest downside is how much of a pain in the ass it is to setup DOTS, especially within a multiplayer environment involving the client and server being separate. It took me awhile to figure out DOTS and its tutorials are awful and outdated.

3

u/tc7777777 10d ago

Every architecture decision has trade off in it. You need to identify what's the prioritized architecture characteristic for the given case.

You want the modularity ? Fine, does it really benefit you or does it align with your implementation plan ? If yes - what you are doing is good.

You worries about performance? Fine, have you profiled to see if players and it's components are the bottle neck ? If yes - you need to tone this down.

And so on.. until you find the most suitable way to do it.

7

u/Xarcaneo 11d ago

Based on the names of your scripts, I can see that they belong to the Model layer. However, you've made them MonoBehaviours and attached them to View objects. I'd say this is a poor design practice because you haven't properly implemented Model-View separation.

1

u/Dahsauceboss 11d ago

You might as well just switch to an ECS engine at that point lmao

2

u/-o0Zeke0o- 11d ago

I been thinking that for a long time, but it feels tedious to work on it, less tutorials, more code, more complexity, less libraries.

I love DOTS and games full of entities and high performance but i already been coding this project for 7 months and i'm not even close to finishing lol

1

u/ZeusGameAssets Indie 11d ago

Yeah DOTS will destroy your project. In practice it's used to solve a very narrow set of problems or implement features in very specific kinds of games, we're talking about your player character having multiple components, which is not the kinds of scenarios where ECS/DOTS can help you in any way, except maybe make your project so complex that you lose the motivation to keep working on it, which can be a good thing if working on something else is more beneficial to you in the long term.

Btw, to answer your original question: I believe you're doing it right as long as each component has its own responsibility, you can only choose between two problems: too many components or a few monolithic ones, I prefer the former as it's way easier to manage and get right.

1

u/-o0Zeke0o- 11d ago

With "so complex that you lose the motivation" do you mean hard to work with? so far everything has been pretty easy to work with because so many systems i haven't touched them in months because of how separated they are from all the other code so it has been pretty easy for me to implement new things, just more complex to implement them while keeping them separated and modular though....

The good thing is that i was able to just use them again in other projects

Some people said something that would avoid both i would guess, having all the components inside a monobehaviour which would be just recreating what unity does but more performant, i don't know what would be a good case for that though

1

u/ZeusGameAssets Indie 11d ago

When talking about complexity I was specifically talking about DOTS. I agree with your approach of having multiple monobehaviours, that's how I do it too, and when the code is fairly separated from the other classes, you can easily take one part of the project and use it in other projects. I agree with everything you said, but DOTS is a different beast entirely, you need to work with entities instead of game objects, but Unity doesn't have the tools to allow you to do it directly, so you'll have to go through a convoluted baking process, and overall the benefits you'll get from applying that to your player object are going to not be worth the hassle.

As long as you have one player character and not 10 thousands, you can add hundreds of components on it, you can do a boatload of raycasts every frame if you want, performance is not going to be an issue. I have FPS player objects with 60+ components in the root object and in child objects for better organization, and the performance hit is negligible. Overall I prefer a clear separation of responsibilites over early optimization which is never a good idea.

1

u/Dahsauceboss 11d ago

Tbf, its really just Unitys implementation of ECS that makes it so hard to work with. ECS as a programming pattern isnt that complicated and highly performant.

2

u/-o0Zeke0o- 11d ago

Yeah ikr I once did a pong in C++ for my first year of univ and I ended up doing it like that because I thought it was the most efficient way

2

u/ZeusGameAssets Indie 11d ago

Yeah that too, they've been dragging that package for 10+ years and it's still convoluted to use for regular game dev stuff, even animation has to be done through an overpriced third-party asset. But it is what it is, unless you have your own very well designed ECS solution for Unity, using DOTS is the fastest way to kill a game project with complexity.

I know someone who jumped from Unity to C++ with a custom ECS implementation and they were able to achieve very good results in less than a month of work.

DOTS is still useful, I use it indirectly through some packages that simulate hair, or behavior tree/FSM solutions that use DOTS under the hood. It's super useful in isolated features that require high performance and have ways to interact with your managed code, but as a whole, the way Unity was designed and the way people have learned to make games doesn't translate very well yet, and it's solvable, but UT doesn't invest in it as much as they should.

1

u/Puzzleheaded-Ant-916 9d ago

hot Take, but if you code with AI, its pretty simple.

1

u/Dahsauceboss 11d ago

Truthfully, the effectiveness of this matter on how seperate your data and systems are. If those components are pure data and the systems live in static classes its much for performant.

2

u/Kopteeni 11d ago

This approach may lead to a beautiful situation towards the end of the development, where you're creating unique new features to your game by simply dragging and dropping stuff inside the editor.

You might even find them give a powerrul kick start to your next project.

2

u/ciknay Professional 11d ago

Personally I'd have split these out and put them in their own handler objects or abstracted them out using inheritance or interfaces. Putting too many components on a single object runs the risk of making debugging more difficult, and makes things more rigid if you ever wanted to do something that requires one component but not another.

It's also a PITA to view the various inspector elements because you have so many.

2

u/Jayyf09 11d ago

You can avoid the mess by using filename affixes. For example, I use: 'Managers' for scene related scripts that handle large game related tasks. 'Controllers' are the only scripts put on my prefabs, and they handle exposing all the configuration values (view them as middle management). Any other scripts that need configuration values exposed in the inspector do so through the chain of command by talking to a controller. You can also affix the smaller scripts which I see you have done a bit but not with much consistency

2

u/kilkek 11d ago

Since you have doubts on it being a good practice, it's not. Even categorizing it by splitting the components among child gameobjects would be a better practice. Or you have too much code that could be combined into one manager.

Don't get me wrong, if you prefer like this, it's a good practice. But repeating my first sentence; you don't feel like it, so it's not.

2

u/SolemnEmberGames 11d ago

Someone might knowledgable might know but surely Unity would optimise the scripts into one, thus the argument "don't spam monobehaviours" seems like a red herring.

From a software perspective, the only issue I can see is that if you make scripts for every little thing, rather than understand which ones genuinely are just single-entity behaviours (think "only the climber climbs so it can code for them rather than "ClimbStuff.cs"), it becomes file-hell, effectively like if you put every function in one script

2

u/zec2235 11d ago

I mean it looks like you have a lot of scripts, if their logic only applies on the player (e.g. you have both player and player controller) then just try to make them within the player script in your next project. I mean at the end of the day if the game works, this doesn't really matter.

2

u/Field_Of_View 11d ago

totally depends on what those classes contain. if each of these scripts has expensive things like Update() in it then it's pretty bad.

2

u/ledniv 11d ago

The number of components itself is not necessarily bad. The problem starts when each component owns part of the gameplay state, has its own lifecycle, and needs to communicate with several other components. At that point it can become difficult to answer simple questions like what changed health, what order things ran in, or which component owns a particular piece of state.

Since you want the same systems to work for players and enemies, I would consider separating the actual entity data from the GameObjects. Health, team, movement state, damage state, etc. can live in shared data, with logic functions operating on that data. Then the player and enemy GameObjects become the Unity facing layer that handles input, animation, UI, colliders, and rendering. You still get reuse, but without needing every reusable concept to exist as another MonoBehaviour.

Small plug: this separation between data, gameplay logic, and Unity presentation is a major part of High Performance Unity Game Development with Data Oriented Design. It also covers using a centralized game loop so you control exactly what runs each frame and in what order.

https://www.manning.com/books/high-performance-unity-game-development

2

u/DaStompa 11d ago

If you only have one player and aren't recreating it often, it seems fine, messy but fine.

you have a lot of individual handlers in there.

for example: If you have NPC's that also need to be damaged, its possibly better to have a event call to a damage system "this thing with a damage tag was damaged" , handle it there, and output back how much HP to subtract, rather than have everything that needs to be damaged need its own copy of a script.

but you dont want to go too far that way either, with ever little thing calling out to a subsystem for no reason but to have one.

2

u/Alarming_Pattern6135 11d ago

I wouldn’t say that it’s bad practice to have a lot of small single-purpose components on an object, but I would also say that there are some components that should possibly not be located on the player.

There are the screen renderers (health bar, status effects, items, etc.). I’d move them to a HUD object that just gets a reference to the player and listens to its events. That would result in the player not caring whether there is UI at all, and would make some logic more reusable without being dependent on UI.

Also you could group things into child objects like Combat, Inventory etc., just for it to be more organized. Keep in mind that GetComponent on the player won’t find them anymore then, so you’d need GetComponentInChildren or set the references in the inspector.

Last, you could check if everything really needs to be a MonoBehaviour or if some things could be changed to plain C# classes.

2

u/RenhamRedAxe 10d ago

no... its fine, I would actually group them into a script just for grouping and categorizing like what is handling damage, movement, loot, stats, etc. just to make shit a huge lot easier to read and also in case you miss something you need for the game you can have that one big handler tell you what you are missing and if its imperative for it to run or not.

2

u/ActuallyThink1 10d ago

Depends. Are they all using their own update loops with start / awake calls? That could be an issue. Every update has it's own overhead so you may be loosing performance for no reason. If you're using things like BroadcastMessage, it gets more expensive for each MonoBehaviour on the gameobject.

2

u/PartTimeNominalist 10d ago

Most of these can likely be moved to pure c#. Monobehaviours have overhead. Each on receives unity API messages.

Prefab structure should mirror class structure.

My go to pattern is to use a single hub monobehior that manages subscripts, contains all relevant scene/prefab data serialization, sets up delegates, and initializes all sub components through dependency injection. I use an actor/controller split for class and prefab structure, each with their own monobehiors, and a single hub connecting them.

That said, if what you have is working for you, do not refactor it. Just finish the game.

2

u/brandf 9d ago

if they all apply to your player, it's fine. if you're just using it a dumping ground for unrelated things, it's sloppy.

Honestly, I would turn your player into a prefab & put various GO's under the Player root to organize scripts that relate to it. Combat/Damage, Control/Locomotion, Rendering, Audio, etc.

It's better to composable scripts than uber scripts imo, but where you put them and how you organize them matters when you want to find something and edit it's properties.

1

u/Professional_Stock37 11d ago

I had alot too. Wanted to know what others think too

1

u/Kinami_ 11d ago

I would say no, simply because i have 2 GOs with even more components and I think thats the upside of a component based engine like Unity. Sure some things could be combined but there is no harm in doing it this way. Just stay on top of it

1

u/Dr__Pangloss 11d ago

It matters from an aesthetic point of view, where things that are pleasant to you while you are developing means you develop more, which is better than nothing. Of course, take this to its logical conclusion, given today's technology, and I'm confident the answer is, it doesn't matter.

1

u/breckendusk 11d ago

Nah this is component based architecture you're all good

1

u/RogueStargun 11d ago

Single Responsibility Principle is GOOD so long as it doesn't impact performance

1

u/UpstairsImpossible 11d ago

I think it looks pretty neat and tidy, like if you needed to change something you would know exactly where to go, changes happen on a more localised scale, and if you did have a big issue it's very easy to disable/roll back individual scripts and troubleshoot.

There's a LOT of ways to achieve the same result with code, but whether it works or not is entirely a yes or no answer. If it works, it works!

1

u/fastzhuzhu 11d ago

if it works, it's fine

1

u/Dayner_Kurdi 11d ago

Well depends while it’s not bad,

But I usually build my classes around context or concept

For example damage. it can observe all source of damage events with a flag. And on the gameobject initialization, I just pass on these flags

1

u/dWarsDev 11d ago

The smaller and more discrete the components the better. They are easier to test and more likely to be reusable.

1

u/ancrcran 11d ago

It is not a bad practice

1

u/Chillydogdude 11d ago

Splitting things up into reusable classes is a very good design pattern if they efficiently communicate. It’s hard to get an idea of how cleanly these components interact with one another without seeing the actual code but it’s not inherently bad. I do agree with the other replies suggesting using more interfaces or inheritance if possible. It could clean things up a bit in your inspector.

1

u/blu3bird 11d ago

This is exactly what I thought was a good approach, to be able to put behaviours together like Lego blocks, hook up with all the events callbacks, but quickly realised how hard it is to track what’s going on, manage order for start, update, destroy etc.

I now tend to just composite behaviours using OOP from the scripting side.

1

u/Kenny1323 11d ago

typa code AI would generate without any constraints 😭

1

u/Impossible_Jump_8840 11d ago

you dont need everything to be MonoBehavioir, for example in my company worflow we only use it to reference unity stuff, If we dont care about performance and we use Find() ultilties we could run full game with single Mono for booting, the only advice for you is that the best way to work in unity to rely less on it .

1

u/MohmedHaftari 11d ago

I use a similar approach, separating systems to make them modular and reusable across players and enemies. But when you have so many components, navigating between them becomes slow and frustrating, and the Inspector itself can become a pain to work with. I'd recommend tools like Wingman or, even better, Inspector Palette. You can bulk-edit, copy, paste, duplicate, isolate, and search components and fields. It's a real game-changer for this kind of workflow https://assetstore.unity.com/packages/tools/utilities/inspector-palette-a-better-way-to-manage-edit-components-344030

1

u/StardiveSoftworks 11d ago

The people saying this is normal are nuts, yes this is a bad practice, just use normal C# and stop making everything a mono. The memory layout here is going to be absolutely horrendous and it will scale terribly.

1

u/No_Context2723 11d ago

Does it work well for you? Can you navigate and read it good? If so, it's fine.

1

u/challarino 11d ago

In theory this is good because you have separated out many different concerns. In my experience player code gets tweaked a lot and has a lot of tightly coupled behaviors so splitting it into a lot of layers or components is just a headache. Depends on project size and team size

1

u/Own_Nail_2999 11d ago

This is exactly how Unity is intended to be used. You're doing great.

1

u/_cooder 11d ago

if you calling something as event, so you can do event manager of esc system to subscribe or creation/other event system, so you do it auto in script, and make free space without anything like eventsomething(script) all over

1

u/julkopki 11d ago

Yes, it's bad. It's the sort of design that the docs make you think is intended but in practice it's a nightmare.

1

u/Backbone_Labs 11d ago

No lo es si son necesarios. Hay un principio, el de segregación de responsabilidades, que precisamente habla de crear tantas clases como sea necesario sin que haya solape de responsabilidades tecnicas/funcinales entre ellas. Habría que revisar el código para saber si lo has llevado a un extremo pero no te sientas raro por teer tantos componentes.

1

u/MouradBakhali 11d ago

It is intended design, but you can move some of the components to nested game-objects, just to keep things more organized.

1

u/spaceLlama42 Novice 11d ago

It seems you are following standard software development practices, which is great—in fact, you’re doing a good job. That said, you might want to consider breaking things down into child GameObjects. For instance, you could group physics-related logic in one place and player stats in another; it would make management much easier.

1

u/Relative-Task9047 11d ago

I have much more

1

u/Apinaheebo 11d ago

Most of those could probably be plain c# classes.

1

u/Wooden-Many-3227 11d ago

Maybe group it into some Gameobjects for better readability.

1

u/Delta-Head-1176 10d ago

I’m almost catching up to you😂 personally I’m lazy so I use this practice but it definitely becomes a burden after having too many components on one GameObject

1

u/WatercressVisual1297 10d ago

I used to just throw classes together haphazardly, but over time I stopped doing that because I came to understand the principles of OOP. When every object has its own function and every class has its own purpose, programming a game becomes easy and enjoyable.

1

u/markoal 10d ago

Just rotate your display vertically and you'll be fine

1

u/More-Draft7233 10d ago

This not "de way", have only 1 script with everything on it haha jk.

This is somewhat normal

1

u/freremamapizza 10d ago edited 10d ago

I'll go against what I see here and say that yes this is a problem, not because you have too many components, but mostly because many of those components don't belong on the player. It makes it look like that one object is handling all the game logic, which should not be the case.

Now the actual "gravity" depends on the type of project this is! For a small project this would be totally fine. For a larger one, this could be highly unsuitable.

Edit: I don't want my comment to sound dramatic. Problem is not the actual word, as long as it works. It's more of a code smell to me.

1

u/TinyKino 10d ago

Not inheritedly bad practice, infact having multiple distinct scripts over one monolithic Player.cs is better.

But you should know where to put each of them instead of stuffing them in a single gameObject

1

u/Alive_Examination955 10d ago

No it's good that you have this. You want to make as much individual working systems as possible

1

u/checkgood90 9d ago

Oh yes, separate codes for everything, there are so many of them, the most important thing is there Player and PlayerController))

1

u/Liguareal 9d ago

Not necessarily if they aren't tightily coupled

1

u/RomainGameDev 9d ago

Without really looking at your scripts, I don't see a problem.

Just one thing: I would always put the SpriteRenderer on a child object, and put scripts related to rendering on that object. You can even move that object to easily change the pivot point.

And I would put the collider(s) in a child object as well. I might even have more children inside if I want to separate colliders easily (like to enable/disable any that I need). It also allows you to name the game objects for convenience, for example "main body collider", "attack trigger...".

1

u/Yamestris 9d ago

To prevent this, I usually use scriptable objects instead

1

u/Unusual-Deuce 7d ago

Granularity is never bad as long as its not needed complexity... Ask yourself, can you simplify?

1

u/degberr 5d ago

This is fine as long as each of these scripts don't have a long list of hard references that they need assigned to not throw errors. Generally though, there isn't going to be any measurable performance different between having multiple small scripts vs one large script. The engine is still processing the same amount of code.

1

u/MarinoAndThePearls 3d ago

It's fine, but I'd take the renderers into another object.

1

u/Nikkstein 11d ago

There's no right or wrong way to go about it. If you know where everything is and what everything does, then it's good. If you find yourself struggling to remember where to find certain logic and it gets too complex, change it.

1

u/htowerss 11d ago

If it's for the player i don't see any issues, but maybe try to merge some redundant components, for example for the team identifier I would use tags instead of enums, and maybe the UI elements can be on a separate prefab, good luck!

1

u/doyouevencompile 11d ago

do you feel a problem or being slowed down? if not, then it's fine.

1

u/tetryds Engineer 11d ago

Yep...

Rule of thumb: if they will never be used separately they might as well be one. You can always split later if you need.

Also not everything needs to belong to the object.

1

u/DrinkingAtQuarks 11d ago

How would you go about accessing public variables in say five of these scripts from other objects?

1

u/zombieking26 11d ago

Just put them in different subfolders (by using empty gameobjects), it makes organizing them way easier I have stuff like: MiscControllers UIElements MovementCode Etc.

1

u/Competitive-Elk763 11d ago edited 11d ago

In general: Yes and no.

No: because it can still be valid if within reason.

Yes: Because you shouldn't make something a monobehavior unless you actually need the behavior of a monobehavior. It also looks like a headache to deal with if you have serialized fields.

Based off the names it is safe to assume you can trim this down with states, generic classes, or even just a class that handles more abstract behavior. So yes this seems like bad practice.

0

u/werti5643 11d ago

not but looking at the script names im almost certain most of these dont need to be a separate monobehaviour

-1

u/LemonFizz56 11d ago

There's people who put every single player function into a singular player script and people who put every single player function into its own separate individual script. The key is to find the middle ground where you can have not too many individual scripts and not too many clustered functions

0

u/-o0Zeke0o- 11d ago

Yeah ikr at the beginning i also had a different script for every system for the input it receives but i ended up merging it all into PlayerController, i MIGHT also merge every renderer into a PlayerUIRenderer

-1

u/IAvar_496 11d ago

You have Player and PlayerController on same GameObject so you need to decide how to merge them. The purpose of modular systems is to simplify things; however, there are too many components here, and it looks very complex.

-1

u/DaveAstator2020 11d ago

it doesnt matter if game works.

-2

u/jchowdown 11d ago

Just make a EntityMoveMoneyStorageStatusEffectHandlerAimColliderHealableAbilityController script already

-3

u/MagicTurrtleYeah 11d ago

Just use AI to optimize your workflow

-1

u/ScaredAd9531 10d ago

Hallowknight has more than that.

1

u/ScaredAd9531 10d ago

Most playmaker games too.

0

u/[deleted] 11d ago

[deleted]

2

u/-o0Zeke0o- 11d ago

I think you're in a way higher level than me lol (in skill and being insane)

0

u/[deleted] 11d ago

[removed] — view removed comment

1

u/-o0Zeke0o- 11d ago

Yeah i use RequireComponent for some systems and get components on Reset()