Search Unity

Most efficient way to code with inputs/vars

Discussion in 'Scripting' started by Crazygamer0872, Jan 19, 2020.

  1. Crazygamer0872

    Crazygamer0872

    Joined:
    Apr 19, 2018
    Posts:
    2
    Hello Unity Community,

    I am thinking about the most efficient way to code something. Let me explain a little first. (Sry for bad english too)

    So imagine i have 2 scripts one for movement and one for my cam;

    One of them checks for input and stores it in variables;
    I also need this vars/values in the other script, so i can work with them;

    So i always think about possibilities:

    1. Method
    I declare a var with the script type to get the public vars and methods from the other script;

    2. Method
    I create a extra script only for vars to read from it;

    3. Method
    I use the scripting again to get input data from the Unity Engine;

    4. and so on
    You guys tell me...

    So my question is, what is the most efficient way to work with vars?
    Or is one of the methods unefficient or bad.

    Or have you guys other ideas for better scripting in Unity;

    Thank you and best regards
    Nuri
     
  2. Nyxal_Indie

    Nyxal_Indie

    Joined:
    Jun 26, 2019
    Posts:
    179
    Crazygamer0872 likes this.
  3. Crazygamer0872

    Crazygamer0872

    Joined:
    Apr 19, 2018
    Posts:
    2
    Ok i was kinda new into game architectures but this helped a lot to find my way into this topic. Thank you.