&& not working?

Hey guys, trying to make this simple program not allow you to move anymore left or right while your on the map, but it is saying that && isn’t a command? Can someone please tell me how to fix it.

void Update()
{
GetComponent().velocity = new Vector3 (horizVel, 0, 4);
if (Input.GetKeyDown(moveL)) && (laneNum>1))
{
horizVel = -2;
StartCoroutine(stopSlide());
laneNum -= 1
}
if (Input.GetKeyDown(moveR)) && (laneNum<2))
{
horizVel = 2;
StartCoroutine(stopSlide());
laneNum += 1
}

The problem is your brackets in the “if”. The whole expression that you’re testing needs to be enclosed within a set of brackets, like this: “if (something && something_else)” but you’re doing this: “if (something) && (something_else)”.

Change your first if to this, and do something similar with your second one:

if (Input.GetKeyDown(moveL) && (laneNum>1))
2 Likes

@MonoBlackMTG please read this.
** Using code tags properly **