Quote:
i cant really understand what it means by the left-hand side of an assignment must be a variable, property or indexer
To add to what Patrice T has said, the error means that when you wrote this bit:
Input.GetKeyDown("f") && KnifePickedUp = true
The system looks at it as an assignment because "=" is an assignment operator, not an equality comparison which would be "=="
And because the operator priority of an assignment is much higher than the logical AND operator "&&" it read it as
(Input.GetKeyDown("f") && KnifePickedUp) = true
Not
Input.GetKeyDown("f") && (KnifePickedUp = true)
As a result, it tried to assign a value to the result of the AND operation and gave you an error that it wasn;t a variable value.
As suggested, you could correct it by changing the assignment to a comparison:
if (Input.GetKeyDown("f") && KnifePickedUp == true)
But since
KnifePickedUp
is a
bool
value anyway, it's a lot clearer to just use that directly:
if (Input.GetKeyDown("f") && KnifePickedUp)