Currently I have some crates that are falling from the sky and are hitting the ground and stopping, which is correct. But when another crate falls exactly on top it is overlapping a bit and then easing back up to where it is supposed to.
local dropLetter = timer.performWithDelay( 1000, newLetter, 100 );[/lua]
I had an event listener in there that converted the crate to static once it hit the ground/item below it
[lua]local function onCollision( event )
if ( event.phase == “began” ) then
event.object2:addEventListener(“touch”, onTapBox )
event.object2.bodyType = “static”;
end
end
Check out isBullet=true, I think this adds extra over head but will mkae collision calculations look ahead. Mostly used to stop bullets flying through walls.
physics.addBody( letter, { density=1, friction=0.4, bounce=0, isBullet=true} );
Let me know what happens. [import]uid: 118379 topic_id: 22905 reply_id: 91471[/import]
Should this type of system be done using physics? or is there a better way of doing it. It has falling blocks that fall in columns and then you can destroy items and the columns should call down to settle at the bottom. No item should ever move left to right, only down. [import]uid: 132533 topic_id: 22905 reply_id: 91476[/import]
Well it can be done with physics but by the sounds of it you could do it without. Your relying on collision detection to hold your objects in place rather then telling your objects to just go to a particular position.
To stop the left and right movement just use a conditional on enterFrame event.
If object.x > 100 or object.x < 100 then
object.x = 100
end
or
If object.x ~= 100 then
object.x = 100
end [import]uid: 118379 topic_id: 22905 reply_id: 91482[/import]
I seem to be able to get them to stay put by constantly setting their x and rotation in the enterFrame event.
But they still seem to “squish” each other. It can be seen where there is alot of them stacked as well as they start to compress. [import]uid: 132533 topic_id: 22905 reply_id: 91493[/import]
seems that setting the frame rate to 60 and upping the physics PositionIterations and VelocityIterations fixes it… [import]uid: 132533 topic_id: 22905 reply_id: 91500[/import]
what about setting gravity to 0,0. Density to 1 and then use a impulse to fire them down. As they have no density / gravity and bounce is at 0 they may just stop dead on collision without overlap.
Food for thought. I my game has gravity zero and it seems to give you more control over certain aspects.