This is my code and I’m getting this error:
Assets/NumberWizards.cs(27,4): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer
On 27th line is print = ("Higher or Lower than " + guess);
not sure what to do with this one.
…
using UnityEngine;
using System.Collections;
public class NumberWizards : MonoBehaviour {
// Use this for initialization
int max = 1000;
int min = 1;
int guess = 500;
void Start () {
print ("Welcome to Number Wizard");
print ("Pick a number in your head, but don't tell me!");
print ("The highest number you can pick is " + max);
print ("The lowest number you can pick it " + min);
print ("Is the number higher or lower than? " + guess);
print ("Up = higher, down = lower, return = equal");
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.UpArrow)) {
//print("Up arrow pressed");
min = guess;
guess = (min + max)/2;
print = ("Higher or Lower than " + guess);
} else if (Input.GetKeyDown(KeyCode.DownArrow)) {
print("Down arrow pressed");
} else if (Input.GetKeyDown(KeyCode.Return)) {
print("Down arrow pressed");
}
}
}
Hello @EmpoweringArts, how are you?
You are getting this erroe because you are writing print = where you should be writing print(something), print("Higher or Lower than " + guess); in this case. You can’t address a value to a method, only to variables.
Thank you! It’s all in the detail!
Mark
1 Like
You are welcome!
Let me know if I can be of further help! 
Ok, now this is a mystery - I’ve change the code but now the console read out is repeating an 8 when pressing either the down or up keys. The second ‘print (…)’ is at 32, corresponding to down arrow code.
Higher or Lower than 8?
UnityEngine.MonoBehaviour:print(Object)
NumberWizards:Update() (at Assets/NumberWizards.cs:32)
…
void Update () {
if (Input.GetKeyDown(KeyCode.UpArrow)) {
min = guess;
guess = (min + max)/2;
print ("Higher or Lower than " + guess + “?”);
} else if (Input.GetKeyDown(KeyCode.DownArrow)) {
max = guess;
guess = (min + max)/2;
print ("Higher or Lower than " + guess + "?");
} else if (Input.GetKeyDown(KeyCode.Return)) {
print("Down arrow pressed");
}
hum… can you paste the whole code? seems to work fine here.
Thanks for taking a look.
…
using UnityEngine;
using System.Collections;
public class NumberWizards : MonoBehaviour {
// Use this for initialization
int max = 1000;
int min = 1;
int guess = 500;
void Start () {
print ("Welcome to Number Wizard");
print ("Pick a number in your head, but don't tell me!");
print ("The highest number you can pick is " + max);
print ("The lowest number you can pick it " + min);
print ("Is the number higher or lower than? " + guess);
print ("Up = higher, down = lower, return = equal");
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.UpArrow)) {
min = guess;
guess = (min + max)/2;
print ("Higher or Lower than " + guess + "?");
} else if (Input.GetKeyDown(KeyCode.DownArrow)) {
max = guess;
guess = (min + max)/2;
print ("Higher or Lower than " + guess + "?");
} else if (Input.GetKeyDown(KeyCode.Return)) {
print("Down arrow pressed");
}
}
}
I’ll try to build it later today to see if I find the problem
That code works fine. I just created a new project, created an empty game object and added the script to it and it works. Can you post a screenshot of your inspector?
1 Like
Hiya, restarted Unity and it all works fine now.
Thank for looking into it.