Search Unity

Is it better to have a single class or multiple classes ?

Discussion in 'Scripting' started by FabioPazzini, Feb 13, 2016.

  1. FabioPazzini

    FabioPazzini

    Joined:
    Aug 5, 2015
    Posts:
    1
    Hi everyone! I would like to ask a question: I'm making a 3D horror game, and I've written the scripts to let the player open the doors (like the doors of the wardrobes, etc...), and everything works properly. But I have a question: is it better to have a single class to open the doors, and use public fields (for the movement and for the rotation) so that I can add the same script to all the doors and assign different values depending on the door (for example, the door of a wardrobe can be opened differently from another door of another wardrobe), or is it better to have all different classes, one for each door? Thanks.
     
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    If you're using C#, then One single "Openabletype" class, and then use "extends OpenableType" and overwrite things.