How to Stack physics Objects Properly

My question is, how do i go about stacking physics objects when i first run a level? i can get it to work for the most part, but i wonder how angry birds does it for example? My objects always just tumble down, for example if im trying to build a pyramid of objects they will just crumble and not hold shape. is it all just a matter of just the right friction properties etc?
any tips would be appreciated

for example, i can get some basic "planks" to stack, but as soon as i put a object on top of those its too heavy i suppose and all falls

Have you tried playing with the density?

yea ill have to try that, i guess it just makes it hard because i want objects to crash through it, so if its really dense then it wont crash through, ill try some different things and let you know how it goes

When I created the Ghosts vs. Monsters sample code, I had that problem initially.

I played with the densities, and tried to get the objects as close to the spot they would fall--as much as possible--so they wouldn't fall from too far of a height before reaching their intended destination.

If you run the GvM sample app, you'll see that when a level starts, each of the level pieces sort of "fall" into place--but not from a very far distance.

Good luck!

oo Jonathan, I didn't know you're working for Anscamobile now. Congrats.

Your samples helped me a lot during my learning process. I truly appreciate you took the time to develop them.

If you check for the cocos2d 's box2d sample, you will find that the boxes are stacked very well. So, I think corona miss something on it.

Yea, its almost like everything has an extra outline, its been mentioned in other forum posts how objects have a transparent border. Anyways i will take a look at ghosts vs monsters, thats probly going to help the most, thanks for your comments

Was there ever a solution to this problem?

Well as far as stacking objects, i was able to adjust density settings just right so things would stack well, but as far as the "transparent" border on physics objects, i never found a solution, its annoying and honestly makes my game look less professional, looks like things are hovering above the ground.

You can manually change the shape around the objects so that they appear to fit closer together. When you add bodies add the shape or radius table to it. Also how did you add objects to your stage. Did you have the physics on and drop them or did you plot them in place and then add physics?

Iv'e tried to drop them and plot them in place and then add physics and both have problems. Is there a way that you think works best?

Well, what I do is start up the physics engine and pause it immediately. Then I add all my physics objects. While physics is paused you can still add in bodies and the objects won't move. When everything is in place,(I usually add a small delay ) I unpause the physics. So that way all the pieces fall into place at the same time versus piece by piece.

Dropping them and looping through to add bodies both cause significant delays between objects that could topple any structure.

On my latest game I paused the physics, imported the blocks with levelhelper, and then added their physical shapes, 1 or 2 pixels less than the dimensions of the image files so they stacked neatly.

My code then generated random stacks of blocks based on a few rules to aid stability, and then I turn the physics on with gravity of 0.2 for 2-3 seconds, so they float gently into place rather than slamming down. When the level is ready I turn gravity back to 9.8.

http://www.youtube.com/watch?v=M6sQNR2pKYg

I'm going to have to look at the android version again as the sheer number of collisions going on doesn't result in a very smooth framerate.

views:1628 update:2011/12/29 9:44:01
corona forums © 2003-2011