Having struggle with approach to a project.

I want to start with a metabolism semi-simulator. In theory it doesn’t sound that complicated, basically, you have calories, macronutrients (carbs, fats, and protein) and possibly micronutrients (vitamins, minerals etc.), simply in form of numbers that go into metabolism “class?”, which “metabolizes” all of it according to as scientifically accurate information as possible I can dig off of the internet. My idea is to make a game in which you have a cartoonish simple character in the middle of the screen, representing body fat percentage and anything that is appropriate. The second part would be food, that basically are items that you mouse drag onto the character to make him consume it. Of course, the food carries all the nutrients and calories that go into aforementioned metabolism system.

Since my former fields where visual and artistic with minimal programming exposure, I am asking for advice or tips on how should I go into this? Should I switch to visual programming software?

Thanks very much to anyone that can help!

That’s my first prototype:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class metabolism : MonoBehaviour {
    public float BMR = 1600f;
    public float BMRinSec = 0.185f;
    public float CalIntakeInSec = 0.185f;
    public float bodyFat = 1f;
    public float glycogenStorage = 0f;
    public float calorieStorage = 1600f;
    public float cancerRisk = 0.2f;
    public float timeScale = 1f;
    public float spacingGUI = 2f;
    public float calorieStorageUpdated;
    public float timeSpeed = 1f;
    public float timer;
    public decimal counter;
    // Use this for initialization
    void Start () {

    }

    void calIntakeUpdate() {
        calorieStorage += CalIntakeInSec;
    }

    void calIntakeStop() {
        CalIntakeInSec = 0f;
    }


    // Update is called once per frame
    void Update () {
        Time.timeScale = timeSpeed;

        timer += Time.deltaTime;
        if (timer >= 1) {
            counter++;
            timer = 0f;

            calorieStorage -= BMRinSec;

            if (calorieStorage >= BMR) {
                calIntakeStop ();
            }
            calIntakeUpdate ();

            if (calorieStorage <= 0) {
                bodyFat -= 0.01f;
            }
            else if (calorieStorage >= BMR && glycogenStorage >= 500f) {
             
                bodyFat += CalIntakeInSec;
                }
            else if (calorieStorage >= BMR) {
                glycogenStorage += CalIntakeInSec;
                }
            }
         
        transform.localScale = new Vector3 (bodyFat, bodyFat, 0);
    }

    void OnGUI() {
        GUI.Label (new Rect (10, 10 * spacingGUI, 100, 20), "BMR: " + BMR);
        GUI.Label (new Rect (10, 30 * spacingGUI, 100, 20), calorieStorage.ToString());
        GUI.Label (new Rect (10, 60 * spacingGUI, 100, 20), "sec: " + counter);
        GUI.Label (new Rect (10, 90 * spacingGUI, 100, 20), "glcgn: " + glycogenStorage);
    }
}

First, please properly insert code so it’s readable.
2nd, don’t use the Legacy GUI system. Just don’t. The Canvas UI system is much more powerful, and has better performance too.
3rd: Should you switch to visual programming? That’s your decision to make. If you don’t want to learn C# (which is easier than you think), then yes. In that case, you can buy Playmaker or use Unreal’s Blueprint system (but then you’d be leaving Unity :(). I’d say do some tutorials so you get a feel for the Editor and C#, then make an informed decision. I’d recommend learning C# as it’s a useful skill and will always be more powerful than any visual scripting tool.
4th: I see you using lots of += with time values. You should use Coroutines instead of adding time floats in Update, both for ease of use and performance. I recommend this:

    IEnumerator DoThing()
    {
        var wait = new WaitForSeconds(0.2f);
        while (true)
        {
            yield return wait;
            Debug.Log("Did");
        }
    }
1 Like