xxxxxxxxxx
// Script calling the function in another script "Script AnotherClass - Function FruitMachine"
public int alpha = 5;
private AnotherClass myOtherClass;
void Start()
{
alpha = 29;
myOtherClass = new AnotherClass();
myOtherClass.FruitMachine(alpha, myOtherClass.apples);
// Debug.Log("alpha " + alpha);
}
// function that is being called in the other script
public class AnotherClass : MonoBehaviour
{
public int apples;
public int bananas;
public void FruitMachine(int a, int b)
{
int answer;
answer = a + b;
Debug.Log("Fruit total answer public: " + answer);
}
//https://learn.unity.com/tutorial/vector-maths?uv=2019.3&courseId=5c61706dedbc2a324a9b022d&projectId=5c8920b4edbc2a113b6bc26a#5c8a4304edbc2a0020d97735