jamessimo Posted July 1, 2014 Share Posted July 1, 2014 Hey guys, I was wondering if any box2D (javascript) users here could help me with this issue I am having. I have some boxes that will float to the top of a block of water. This function works fine //if inside the water this.waterObj.GetBody().SetLinearVelocity(new b2Vec2(0,-2));I want my water take the boxes like a wave, however when the water block collides with the boxes, the collision handler is NOT called… However if I drop my boxes into the water it works fine (even if the water block is moving) I think this is to do with the collision handler not being called on my blocks if they are stand still, I have setthe bodyDef.allowSleep = false;at creation and even reiterated throughout the boxes to check that sleeping is off; but this hasn’t changed anything, I even set the whole world sleep to false. Can anyone help me get the water collision handler to trigger if it hits my stand still (not sleeping) blocks? Cheers! Quote Link to comment Share on other sites More sharing options...
jamessimo Posted July 6, 2014 Author Share Posted July 6, 2014 To help illustrate my problem, here you see the blue water rising, If moving blocks (the maroon + orange one) they float as expected. But the blocks at the bottom are at a stand still. Quote Link to comment Share on other sites More sharing options...
furka Posted July 17, 2014 Share Posted July 17, 2014 at creation and even reiterated throughout the boxes to check that sleeping is off; but this hasn’t changed anything, I even set the whole world sleep to false. do you mean they are actually sleeping and allowSleep = false; does nothing, or do you mean doing this doesn't actually fix your problem? Could it be that you are using the wrong collision handler? You have BeginContact and PreSolve Quote Link to comment Share on other sites More sharing options...
jamessimo Posted July 23, 2014 Author Share Posted July 23, 2014 Oh forgot to mention that I fixed this problem by doubling the AABB collision handler.the box would be fixutre A if clicked but if it was collided by the water it would be fixture B. So now I just say somthing like if(contact.fixtureA == box || contact.fixtureB == box){//THEY ALL FLOAT} Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.