Proper scripting process/layout

Hello. I’m trying to learn unity3d and scripting and what I really need to know is - well - what’s the proper way to setup scripts? Looking at the Locomotion System it appears that a player requires: A character controller, character motor, and an input controller.

I’m not sure what controller does. It appears that motor handles complex animation/movement functions while input calls these functions when the appropriate buttons are pressed.

Why split up all of these scripts? I would assume it’s to make it easier to change out scripts for different functionality? What would be the proper way to “design” what script should go on what objects and what scripts you should make?

Like say, for example, a gun. You would need a gunMotor and gunInput right? gunMotor containing information like clip count, remaining rounds, fire rate along with fire/reload/etc functions; and gunInput detecting clicks and calling fire(), reload(), etc etc functions inside of gunMotor?

I hope I’m making sense.

Thanks for your time.

~ Sean

That’s the funny thing with scripts, you get to compile them, looking at the Locomotion system would confuse you. That’s done seperately to avoid one gigantic/complex script. Using your gun example, just think of what your trying to achieve “Shooting”, the nessecities “variables such as bulliet prefabs and where to shoot them from” and develop the processes “place bulliet prefab here to shoot and subtract ammo count by one”. You’d just have one script with set variables and detects input from the user that when the appropiate input is recieved and certain action is done" I might not be explaining it well but you might want to check the Docs out : Unity - Scripting API:

Ah, sweet. That makes sense. You see I was thinking that way because I come from an PHP/OOP background where every object used in the program would be a separate script/class (one for individual items (db results, forms, user information), one to control these items, one to control these controls), so I was wondering if the same applied here. But apparently not :slight_smile:

Thanks for the help!