Arek Marcjanik
Arek Marcjanik

Reputation: 105

How to check if one number is higher than other by value of 3?

How to check if NUM1 is higher than NUM2 by value of 3 and vice versa? in C# for Unity5

But NUM1 & NUM2 will increase value further the game goes.

(than do something)

example:

Num 1: 4, Num 2: 7 = True (than do something)

but in some minutes it might be

NUM 1: 5, NUM 2: 7 = false (than do something)

I have just basic IF statement but that works only for one value of NUM1 and NUM2, but if it changes I would need 100 of if statements for my project.

Upvotes: 1

Views: 481

Answers (1)

William V.
William V.

Reputation: 343

bool greaterByComparer(float num1, float num2, int comparer)
{
    return Math.abs(num2 - num1) == comparer;
}

Upvotes: 5

Related Questions