Best way to constrain actor within boundaries

butterbeanbutterbean Member, PRO Posts: 4,315
edited November -1 in Working with GS (Mac)
What's the best way to constrain the player within the boundaries of the width of the level?

Constrain attribute or create an invisible wall?


  • KamazarKamazar Member Posts: 287
    It depends on the game. Personally, I like the invisible walls more because it allows the player's actor to kinda bounce off instead of just stopping. Feels more natural, and in some cases, can be used as a gameplay element. But I suppose in a more traditional platformer, contraining attributes would be more elegant.
  • harrioharrio Member Posts: 234
    what's cookin,

    kamazar is right in saying it depends on the game and the style you want to portray.

    also, there is a third way to contain actors. by simple math with your controllers.

    for example, i'm working on a space invaders clone in which i don't use invisible walls or constrain attributes. i simply use variables that represent my barriers like...left border, right border etc. then i have the movement controllers ignore key commands or perform certain functions when the actor positions equal these variables.

    one reason i did this is apparent in the invader demo that codemonkey made. it lets you move the player left and right to the far screen borders, but when you hit a border and continue laying on the movement key, you can see the player icon reacting to the physics of trying to push through the border. the actor kind of jitters and vibrates as it's trying to continue moving through an invisible obstacle.

    well, i wanted old school movement where, when you hit the limit of either side, you just stop dead and smoothly. no jitter, even as you hold the key. by using math, you accomplish this with no physical borders needed.

    but again, it depends on the style of game. if you're a retro-blaster shooting aliens, you want to stop dead at the edges. if you are a stock car racer, or a tank you may want that physics type 'grinding' feel, as an illusion of realism. it all depends.

    hope this helped...
Sign In or Register to comment.