Hi, I’m new to Unity and C# coding, I’m trying toenter code here
make this simple script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class myLight : MonoBehaviour
{
public int int1;
public int int2;
public Light Lamp;
void Update() //If Sum of the 2 integers is 10, then the lamp will be turned on
{
int final = TenSum(int1, int2);
if(final = int (10)) {
Lamp.enabled = true;
} else {
Lamp.enabled = false;
}
}
int TenSum(int int1, int int2) //Return the sum of 2 integers together
{
int Return = int1 + int2;
return Return;
}
}
So apparently on the line “if(final = int (10)) {”, Visual Studio says that it is an invalid expression term.
What went wrong?