Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

How to plan and structure your code in Unity?

$
0
0
Heyo, I'm new to Unity and have been wondering a bit on how to best structure the scripting part. What are the good practices? Bad? Currently I am adding a script component for each script which are based on what the script does, just to keep them apart and focused on their function. Ex. Have everything to do with combat in one script, selection in another, movement in one, etc. And then use getComponent on the object if i need them to communicate in some way. Is this ok? It seems kinda off, even though having the code keep their single responsibility usually is good.. Would it be better to use script component, and then add the other parts as regular classes in that script? Last night i found this example, is it a good way of working with unity? I'm not asking for a enterprise solution as i am just starting out with unity(but i work as a developer in c# & more), as i don't want to spend too much time when i have barely something to improve, just something to use as a guide in the future.

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>