Adding variables

Hi so I want to multiply two variables and set the outcome to another variable, however, I always get an error. Here’s my code

public class IntegersValues : MonoBehaviour
{
public float Multiplier = 0.02f;
public float BaseMulti = 100f;
public float Endmultiplier = Multiplier+BaseMulti;
}

Make Multiplier and BaseMulti static :

public static float Multiplier = 0.02f;
public static float BaseMulti = 100f;

But I suggest you not to initialize a variable like that. Declare the variable and make the calculation inside a method like start() for example :

   public float Endmultiplier;
   public float Multiplier = 0.02f;
   public float BaseMulti = 100f;

void Start()
    {
        Endmultiplier = Multiplier + BaseMulti;
        // this will show the value of Endmultiplier in the Console
        Debug.Log(Endmultiplier);
    }

Hi, so i’m trying to do this with what you gave me, however the text doesn’t
work. Can you please help?

public Text MPSingapore;

public Text EcoSingapore;
public float SingaporeMultiplier;
public float Multiplier = 0.02f;

void Start()

 {
     SingaporeMultiplier = Multiplier * 5545000;
     
     Debug.Log(SingaporeMultiplier);

     MPSingapore.text = SingaporeMultiplier.ToString();
 }

Your code will work if you make Endmultiplier a property, you declare it like public float Endmultiplier {get(return Multiplier+BaseMulti;} } or just make a method to do it.