r/unity_tutorials • • Feb 15 '20

How To Separate your Player Code into Different Script components (useful advice for beginners) ►

https://www.youtube.com/watch?v=_vj1GASSO9U
113 Upvotes

12 comments sorted by

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.

3

u/MegaStegz Feb 15 '20

It just started happening for some reason. it plays fine when i view it in youtube studio. Confounded youtube. might have to re-upload

4

u/thegreatuke Feb 15 '20

Thank you for the breakdown of this topic!

2

u/MegaStegz Feb 15 '20

You are very welcome! And to you for the comment :)

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

u/tarexelion Feb 16 '20

Makes sense, thanks!

2

u/ambid17 Feb 16 '20

No problem!

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

u/Dyu91 Feb 20 '20

I LOVE this developer's videos!

2

u/MegaStegz Feb 21 '20

You are awesome!! <3