Jump to content

Collision built in Physics


zurcxer
 Share

Recommended Posts

Hi Pandajs experts!
 
I have this 2 bodies in a world.
 
body1 is a rectangle.
body2 is a circle.
 
I also have a ground.
 
I want to make these 2 bodies fall in the ground.
 
Rectangle falls and hit the ground.
 
But the circle continues to fall.
 
       
this.world = new game.World(0, this.gravity);var groundBody = new game.Body({position: {x: game.system.width / 2, y: 750},collisionGroup: 0});var groundShape = new game.Rectangle(game.system.width, 100);groundBody.addShape(groundShape);this.world.addBody(groundBody);var x = game.system.width / 2;var y = 600;body = new game.Body({position: {x: x, y: y},velocityLimit: {x: 100, y: 1000},collideAgainst: 0,collisionGroup: 1,});var bodyShape = new game.Rectangle(200, 30);body.addShape(bodyShape);game.scene.world.addBody(body);body2 = new game.Body({position: {x: x, y: y},velocityLimit: {x: 100, y: 1000},collideAgainst: 0,collisionGroup: 1,});var bodyShape2 = new game.Circle();body2.addShape(bodyShape2);game.scene.world.addBody(body2);
body.mass = 1;
body2.mass = 1; 

 

Do you have any idea?

 
 
 
 
 
 
Link to comment
Share on other sites

I think game.Circle class has a default of 50 as its radius.

 

Even if I change it. It falls endlessly. :(

 

I think that in engine is now missing solution of hitResponse for case when collide circle with rectangle. If you will look in physics module and you focus on class game.CollisionSolver (exactly hitResponse method on line 258) you will see that there is code for collision between two rectangle bodies and two circle bodies but missing for combination of rectangle and circle body and also for line body. So probably there is your problem I think.   

Link to comment
Share on other sites

@enpu I know. I had same problem as described above @rexternberg so I made some exploration in engine code and found reason where is the problem. I'm new in HTML5  gaming so now I'm trying some HTML5 engines and I have to say that your engine is my favourite for now. Very understandable code and nice examples. Great job! 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...