Chaos Rush Posted February 14, 2009 Report Share Posted February 14, 2009 I'm having trouble with some physics. So lets say that there's 3 crates stacked up on top of each other. Sonic destroys the crate at the bottom. Then the crates above the one that Sonic just destroyed should be falling, right? Well I'm having trouble replicating that. Here are the object properties: Name: objWoodCrate Parent: objParentBreakableTerrain Create Event: Gravity = 0;GravityForce = 0.2185;Ground = true;Limit = 64;MaxLimit = y+64;[/CODE]Step Event:[CODE] vspeed = Gravity; if (Ground = false) Gravity += GravityForce; if (Ground = true) Gravity = 0; if (place_meeting(x,y+Limit,objParentBreakableTerrain) || place_meeting(x,y+Limit,objParentTerrain)) { Ground = true; } else { Ground = false } if (y > MaxLimit) y -= 1;[/CODE]To help explain, here's some pics:1. Here Sonic looks up at the stack of crates.2. Sonic destroys the bottom row.3. Here Sonic looks up only to realize that the crate above only moved a few pixels down, and that Newton's laws are lying. Link to comment Share on other sites More sharing options...
Vexus Posted February 14, 2009 Report Share Posted February 14, 2009 Try replacing you Step event code with this: y += Gravity if (Ground = true) Gravity = 0; else Gravity += GravityForce; if (collision_point(x,y+Limit,objParentBreakableTerrain,0,1) || collision_point(x,y+Limit,objParentTerrain,0,1)) { Ground = true; } else Ground = false; while (y > MaxLimit) y -= 1; The 'place_meeting' function is probably the culprit though, as it could have counted itself when checking for collided objects. This is why I've used the 'collision_point' function, it makes sure that it doesn't count itself during the collision checking. Link to comment Share on other sites More sharing options...
Chaos Rush Posted February 14, 2009 Author Report Share Posted February 14, 2009 That partially works. If Sonic destroys the first row, then the one on top falls as it should. But if he destroys the one that just fell to the ground, the one above that one doesn't fall, it just bounces a few pixels back and forth. Link to comment Share on other sites More sharing options...
Recommended Posts