- Home /
C# adding ints
Hi i am new to C# and i want to try and make a simple game. The game is when a box is clicked add int A to int B and let the answer be A.
eg. A=1 B=2 A+B=A A=3
I know you can do his in java script but can it be done in C#???
Answer by JayOhhh · May 30, 2014 at 03:15 PM
public int A = 1;
public int B = 2;
public int result;
void addMaths() {
result = A + B;
Debug.Log("result = :" + result);
}
Thanks. But what I want to try and do is add A to B every time the button is clicked. A=1 B=2 Then get an answer of 3 next click an answer of 5 then 7 and so on. Can this be done or should I just use java script??
It is done the same way in either C# or Unityscript.
In your update function, call http://docs.unity3d.com/420/Documentation/ScriptReference/Input.Get$$anonymous$$ouseButtonDown.html
Your answer
Follow this Question
Related Questions
(C#) Public variables that have descriptions in the engine. 2 Answers
(C#) For loop variable value not changing 0 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer