I’m trying to create what I thought would be a simple box2d world, where some objects begin static, others fall down and bounce off the static ones as they fall, then eventually the static ones fall off the bottom of the screen too.
This is my first real attempt to use box2d for anything, i’ve done a bit of reading and playing around and I think I can see a few ways of doing it, but none of them seem ideal.
Is it better to keep the world’s gravity off, and use updatebody to make half the objects fall to start with, either with position or velocity? Then change the position or velocity of the (initially) static objects later to make them fall too?
Or is it better to have the world’s gravity turned on but set the (initially) static bodies mass to 0 so they are unaffected by it, then later use updatebody’s position pin to make them fall off the bottom of the screen?
any hints and tips gratefully received, thank you!
I think I’d start with gravity and have mass 0, then setbody velocity to the static boxes, you might have to update the static bodies postions to keep them in place when they get knocked by falling bodies though.
Or create falling bodies at the locations of the static boxes and at the same time kill the static bodies.
Thanks Catweasel, killing the static bodies and creating new ones in their place turned out to be far the easiest method.
However, it has made another aspect more tricky.
The static (and then later dynamic ones that replace them) bodies are textured with a ‘1’ while the constantly falling bodies are textured with a ‘0’
So, updating the spread of textures when i start killing bodies and creating new ones in their place, which also need to keep the same texture is taxing my 4V knowledge and spread understanding to the max!
I’m pretty sure it’ll involve a select node, and maybe a reorder? But beyond that I’m struggling a bit. Any suggestions on how best to approach this problem?