r/gamedev • u/MegaStegz • Feb 15 '20
Tutorial How To Separate your Player Code into Different Script components ►
https://www.youtube.com/watch?v=_vj1GASSO9U6
u/MegaStegz Feb 15 '20 edited Feb 15 '20
edited: The audio sync has self corrected. some youtube glitch. Thanks to those who let me know.
7
u/Avahe Feb 15 '20
If this is Unity specific, could you put Unity in the title next time around? And thanks for your post
5
3
u/Jaedong9 Feb 15 '20
Well I'm using Godot and the same concepts applies, separting your code is important regardless of the platform =)
2
u/Gonzako Feb 15 '20
I always do this! I mostly do it so the AI moves more or less the same way as the player and they feel "in the same world". Also, interface everything and you got an Iterators dream
0
u/runslikewind Feb 16 '20
Got excited because this is what i'm struggling on. until i saw it was unity.
1
u/Bmandk Feb 16 '20
If you have a similar engine that also uses components, then it's still applicable.
Generally, he's pretty close to a ECS system, which is starting to become more popular with the bigger devs. It's something you might want to look into.
2
-4
u/AutoModerator Feb 15 '20
This post appears to be a direct link to a video.
As a reminder, please note that posting footage of a game in a standalone thread to request feedback or show off your work is against the rules of /r/gamedev. That content would be more appropriate as a comment in the next Screenshot Saturday (or a more fitting weekly thread), where you'll have the opportunity to share 2-way feedback with others.
/r/gamedev puts an emphasis on knowledge sharing. If you want to make a standalone post about your game, make sure it's informative and geared specifically towards other developers.
Please check out the following resources for more information:
Weekly Threads 101: Making Good Use of /r/gamedev
Posting about your projects on /r/gamedev (Guide)
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
33
u/Orava @dashrava Feb 15 '20 edited Feb 15 '20
Good practice, but the execution could use some further polish.
The reference clutter in the inspector and manual fiddling to set it all up could be automated to make it foolproof and a lot cleaner.
Using
[RequireComponent]would make it so it can't be set up wrong, and make it quite a bit simpler to set up further characters, since you could simply drop any of the scripts on a GO and the others will be added automatically.Manually messing with the execution order can end up getting really bloated as the project grows. It's nice to see things visually in the execution order, but it's further manual and error-prone work you might as well skip. The main script could be initializing all the modules ensuring that things exist in the order you need them.