r/unity_tutorials • u/MegaStegz • Feb 15 '20
How To Separate your Player Code into Different Script components (useful advice for beginners) ►
https://www.youtube.com/watch?v=_vj1GASSO9U4
4
u/tarexelion Feb 15 '20
Why should we seperate these scripts? Is it for performance optimisation or just for better organization?
6
u/MegaStegz Feb 16 '20
It's primarily to separate the concerns of the classes. Easier to debug, less chance of inter-logic conflict - as well as a means to create re-usable components. It is not mandatory, but a useful strategy.
7
u/ambid17 Feb 15 '20
I find it most useful for re-usability. If You make a new game and want 2D movement but with a more slippery collision, just grab your old 2D movement script and make a new collision script.
2
2
u/mattcj7 Feb 17 '20
It pertains to the SOLID principle and classes having only one job and doing them well and keeping your code modular and simple.
1
6
u/sEi_ Feb 15 '20
Idk if it's only me, but the audio is not synchronized with the video. A little desync i find ok, but this is so far off that i stopped looking because it hurts. - Would love to see a sync'd version.