Search Unity

Oxygen Bar Help

Discussion in 'Scripting' started by kyogretcg, Nov 28, 2012.

  1. kyogretcg

    kyogretcg

    Joined:
    Nov 28, 2012
    Posts:
    4
    Hello everyone, this is my first time posting but I had a question that I just don't know where to begin. I am in development of a Slender variation which I have many questions (mostly scripting) on but I'll leave those for another thread, anyways I want to create an oxygen bar that decreases over time and decreases at a faster speed when you run I want the max time allowed to be 20 minutes and decrease at a slow pace but increase if you run (as stated before) and I have no idea where I should begin with the scripting. It seems rather stupid of me to attempt game making when I have no knowledge of coding. If you could please let me know a solution I would greatly appreciate it my other questions include a Slenderman follow script a script for clicking pages (I know how to make them disappear and add to the count) and also how to have him kill you. any answers are greatly appreciated. Thanks.
     
  2. diegzumillo

    diegzumillo

    Joined:
    Jul 26, 2010
    Posts:
    418
    Yes, you should learn how to code properly, this should be a trivial task to anyone who wants to start developing games.

    I would use a couple of variables like oxygen, to store the total value, and oxygen_consumption, to store how fast it consumes. Every frame (thus inside an Update() function) you set oxygen -= oxygen_consumption. And the variable oxygen_consumption can be altered when changing state. For example, when changing to 'running' you can set oxygen_consumption += 2 (just remember to set it back when leaving this state). This way you can have several different activities at the same time influencing how much oxygen is consumed.
     
    alistairlacey15 likes this.
  3. kyogretcg

    kyogretcg

    Joined:
    Nov 28, 2012
    Posts:
    4
    great thank you and do you know of any good websites to help me learn
     
    alistairlacey15 likes this.
  4. diegzumillo

    diegzumillo

    Joined:
    Jul 26, 2010
    Posts:
    418
    The unity documentation is pretty good!

    http://unity3d.com/support/documentation/

    Right at the first screen you'll read "Getting Started - If you're new to Unity, you should start here" :)

    Good luck there, come back to the forum when you have questions

    edit: from a quick look, the "basics" link seems to be just about the editor, but the second link is to example projects which are well documented and serve as great guides to program with unity.

    Also, if you want to learn programming in a more simple environment, try python. It's one of the easiest ways to learn programming.
     
    Last edited: Nov 28, 2012
    alistairlacey15 likes this.
  5. kyogretcg

    kyogretcg

    Joined:
    Nov 28, 2012
    Posts:
    4
    well I understand unity infact my game is complete except for the coding thats the only part that confuses but thanks for the help