Hi Everybody!
I’m just new with Unity and I was trying lo learn something from a tutorial. This one:
And here’s the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
int Mario = 5;
// Use this for initialization
void Start () {
Mario = MultiplyByTwo(Mario);
Debug.Log (Mario);
}
int MultiplyByTwo (int Paolo){
int calcolo;
calcolo = Paolo * 2;
return calcolo;
}
// Update is called once per frame
void Update () {
}
}
I gave random names to variables just to see if I got the meaning. I’ve also understood everything in the the tutorial except for one thing: I still don’t understand how in this function:
int MultiplyByTwo (int Paolo){
int calcolo;
calcolo = Paolo * 2;
return calcolo;
}
the temporary variable “Paolo” got the value of 5. I’m pretty sure it got it from this variable:
int Mario = 5;
But how?! The console at the end prints 10 as number.
Thx for your helps.