Jump to content

Phaser 3 Matter Physics - pause collisions


Recommended Posts

I am making a  2d cross country horse riding game. The player will be able to move left and right and jump obstacles. I use tiled to make the obstacle course.

I want to use matter physics because I needed detailed obstacles rather than just simple shapes. 

I have also used collisions because I could not find any other way to define whether a user has hit an obstacle on a tile layer. As I am not using collision physics (game over when I hit a obstacle) maybe there is a way better way of doing this game. Here is how I set up the collision:

const road = this.make.tilemap({key:"map"});
const roadTileset = road.addTilesetImage("terrain", "tiles");
const belowLayer = road.createStaticLayer("bot", roadTileset, 0, 0);
const collisionLayer = road.createStaticLayer("collision", roadTileset, 0, 0);
const treeLayer = road.createStaticLayer("tree", roadTileset, 0, 0);
//const topLayer = map.createStaticLayer("top", tileset, 0, 0);
//collisionLayer.setCollisionByProperty({ collides: true });
collisionLayer.setCollisionByProperty({ collides: true });

player physics set up as follows:

player = this.matter.add.sprite(400,6300, "player").setOrigin(.5, .5);
type: 'circle',
radius: 6


I am now trying to get the player to jump over barriers with collides property, I was hoping to do so by pausing the collides property for half a second or so to allow the player to move through when the jump button is pressed, but this is proving more difficult than anticipated.




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.

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.


  • Recently Browsing   0 members

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