More efficient: more code or constraints?

I was wondering if I could get your thoughts on what would be more efficient requiring less work for game salad. Having a simple constraint to do a process, or adding a line or two of code but removing the constraint.
I have two examples.
My game is a platformer were the character is always running, like rayman fiesta run. The character runs at two speeds depending on if you hold the sprint button. I have the speed constrained so that if bump into an object or a wall and slow down, once you clear the object you immedietly start running again. Would it be more efficient to add a line of code that says
If Linearvelocity.x is less than "maxspeed" then constrain the speed to "maxspeed" and otherwise if it is less change speed to "maxspeed" then just have my sprint button being released or pressed change the "maxspeed"
It would add another line of code but would it be better than constantly having a constrain

Similar example, there are many times i need to know if my character is moving up or down (animations, jumping on heads) is it better to just contain the y velocity to an attribute or add a rule saying
If linear velocity.y is > 0 change attribute to UP
otherwise change attribute to down

Comments

  • slowcutslowcut Member, PRO Posts: 164
    Hi it would not slow down your performance if you use some constrain behaviors in your game.

    But it is always better to find workarounds to replace as much constrain behaviors as yo could.

    The running behavior of your main actor is a basic function of your game. If it works fine, I would not replace it.

    But if you have lots of constrains in your enemies, obstacles, etc, then I would think of some other solutions for them. Instead of using lots of comparing rules to check the state of attributes, try to think about using a little bit of math in the expression editor.
    Magic things can be done in there.

    It is always nice and easy to create lots of rules in GS, but you can always combine several rules into one formula by using expressions and well thought logic.
  • @slowcut thanks for the advice. Do you know if there is a list somewhere describing each of those different math functions in the expression editor. It has been a while since my last math class and I am not sure what a lot of those abbreviations stand for. Thanks.
  • slowcutslowcut Member, PRO Posts: 164
    Yes there are lists and description of the expression editor functions in several places

    A good place to look is google, searching this forum is also a good starting point, and they are listed inside the GS manual

    http://cookbook.gamesalad.com/definitions
  • Thanks, already see a way one function can help simplify one of my actors
Sign In or Register to comment.