Better to separate rules or nest them in each other?

ShaneS429ShaneS429 Member Posts: 77
edited November -1 in Working with GS (Mac)
Just a general question. Say you are doing a comparison or seeing if an attribute = 1 of 5.

Is it better to nest the rules within one another such as

Is *attribute* = 1?
YES - Do some action
Otherwise - Is *attribute* = 2?
YES - Do some action
Otherwise - Is *attribute* = 3?

etc.

OR Separate all the rules?

Is *attribute* = 1?
YES - Do some action
Otherwise - Do nothing

Is *attribute* = 2?
YES - Do some action
Otherwise - Do nothing

Is *attribute* = 3?
YES - Do some action
Otherwise - Do nothing

Splitting them up seems like it would be easy for me to read, find appropriate rules, but if they are separated, wouldn't the game be checking each rule each time the game runs the update cycle?

But using technique 1, if the attribute has to equal 5, it would have to run through each other rule anyway.

Any benefit in terms of processing or fps for either way?

Comments

  • m456arcusm456arcus Member Posts: 189
    In the platformer tutorials, it said that nesting them means the game wouldn't have to check each rule. Still, people say that things like this are not going to make a very big difference anyways, so no big deal. For me, I nest rules if possible, just out of habit.
Sign In or Register to comment.