Best way to constrain actor within boundaries
butterbean
Member Posts: 4,315
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?
Constrain attribute or create an invisible wall?
Comments
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...