Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Having Weird Issues with Physics.


Dmitrix
 Share

Recommended Posts

Hello,

 

So I've been having some weird issues with Physics in Phaser. I'm porting a game I previously made in Lua and Love for Ludum Dare. It's a simple game where you play as this giant monster who squashes cute little bunnies. Anyways, so the issue I'm having is that when the bunnie is falling and falls on to the player while the player is falling the player will start moving really fast and will get moved into the ground. Also, I was having issues where the bunnie would be on top of the player but it would make it so the player could barely jump. So I lowered the Bunnie's mass and the when the player would jump sometimes it would jump really high really quickly.

 

You can try it here: http://dmitrix.com/bunnie/test

 

Use AD and SPACE to move the player and Arrows to move the bunnie.

 

TL;DR Is there something wrong with Phaser physics or do I just suck at coding?

Link to comment
Share on other sites

Hey, Dmitrix. Please post us some piece of code. Might be something wrong with the gravity, but I'm not sure.

 

hmm... I'm not sure which parts of the code I should post specifically.

 

Here is where I create the player and bunnie in the create() function:

 // ADD GROUND                ground = game.add.sprite(0,600-50,'ground');                ground.body.immovable = true;                                // ADD PLAYER                player = game.add.sprite(0, 0, 'player');                player.body.gravity.y = 10;                player.body.collideWorldBounds = true;                player.body.bounce.y = 0.1;                player.body.mass = 1;                                                player.body.setSize(100, 283, 150, 0);                                player.anchor.setTo(0, 0);                                 // ADD BUNNIE                bunnie = game.add.sprite(450,0,'bunnie');                bunnie.body.gravity.y = 8;                bunnie.body.mass = 0.1;                bunnie.body.bounce.y = 0.1;                bunnie.body.collideWorldBounds = true;                bunnie.frame = 1;

Collisions:

game.physics.collide(ground, player);game.physics.collide(ground, bunnie);game.physics.collide(bunnie, player);                

and player jumping:

 // CHECK JUMPING                if (player.body.y >= 600-350 && player.body.touching.down){                    jumping = false;                }else{                    jumping = true;                   }                                // JUMPING CONTROLS ( SPACE )                if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)){                    //console.log(jumping);                    if (jumping == false){                        player.body.velocity.y = -350;                    }                    jumping = true;                }

If you need more just let me know. I could put the whole thing on paste bin or something.

Link to comment
Share on other sites

I don't see anything obviously wrong with the code. it's probably due to some issues with Phaser 1.1.3's physics. Rich is working on addressing these and 1.1.4 is hopefully going to make thing much better. (and should be out soon)

 

in the meantime, try playing with the mass values. I'd try cranking the monster's mass up instead of the bunnies' down - those seem like very low values to me... playing with some different numbers might get you better results. (or not, but one can hope!)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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