Hi there, I’m trying to find a way to sort of “flip” the > and < operators in an if statement. I’ve looked through some c# documentation but I haven’t found anything so I thought I’d ask here.
Here is my current code:
if (Input.mouseScrollDelta.y < 0)
{
Down();
}
else if (Input.mouseScrollDelta.y > 0)
{
Up();
}
So as it is right now, if I scroll down on the mouse wheel, the Down()
method gets called, and if I scroll up the Up()
method gets called.
What I want is to give the player the ability to flip this. So scrolling down will call Up()
and scrolling up will call Down()
.
The only way I can figure out to do this though is the following code:
if (Input.mouseScrollDelta.y < 0)
{
if (flip)
{
Up();
}
else
{
Down();
}
}
else if (Input.mouseScrollDelta.y > 0)
{
if (flip)
{
Down();
}
else
{
Up();
}
}
Where flip is a bool. I just want to know if there’s a cleaner way of doing this. I feel like there should be but I’m just not sure.