- Home /
Double checking inputs or communicating scripts ? efficiency question
Hello everyone, i have a simple question about organizing my scripts. In my game, i have a script called anim controller, which checks player inputs in order to determine if we are running, jumping, walking or simply idling and plays anims through animator according to these situations, i handled the logic with booleans as you could imagine. Now, i am going to write my character controller script, which will adjust the speeds and velocity values of the character depending on player input. What i like to ask is, should i make the input checks in my character controller again seperate from my anim controller ( game already checks the inputs in my anim controller as i said, and inputs will be the same with char controller, just wasd shift key and space key ) or should i make the char controller script to communicate with anim controller, and behave according to the booleans over there. Im asking this because i care about the script optimization, which will be more efficient. Im coding in c#, thanks in advance :)
Answer by Kiwasi · Dec 17, 2014 at 08:56 AM
The primary point to focus on at this stage is code maintainability and work flow efficiency, rather then performance.
I typically suggest handling all of your input in once in one class. That way if you decide you need to change keys later there is only one class to modify.
Well i have no problem about maintaining the scripts right now, so you say that controlling all input from one script and reaching it through other scripts is a better way ? I only want to know if communication betwren scripts will cost more performance or not .
Your answer
Follow this Question
Related Questions
Reading input outside of Update or some other ticking system 2 Answers
checking for keyboard input with exceptions 0 Answers
Unable to check input action 0 Answers
Input for each type of character 1 Answer