Lefota Posted September 4, 2017 Share Posted September 4, 2017 Hi Everyone! Hopefully someone can help with the issue I have faced. I am building a simple racing game and want to implement collision between car and other objects. I am using p2 physics. When I create primitive body objects (e.g. body.setRectangle) collision works fine, but when i use polygon (body.loadPolygon) i have created in PhysicsEditor the car just rides throw these objects without any collisions. I have tried building very simple objects to exclude "holes" in collide, creating collision groups but unfortunately any of these things helped. Attaching my code and a screenshot Car class: export default class extends Phaser.Sprite { constructor ({ game, x, y, asset }) { super(game, x, y, asset) game.physics.p2.enable(this, true) this.anchor.setTo(0.5) this.body.clearShapes() this.body.loadPolygon('physicsData', 'car') this.body.angle = -90 this.cursors = game.input.keyboard.createCursorKeys() this.velocity = 0 } Obstacle code: create () { this.game.physics.startSystem(Phaser.Physics.P2JS) this.game.physics.p2.defaultRestitution = 0.8 this.map = this.game.add.tileSprite(0, 0, 2880, 1620, 'map') this.game.world.setBounds(0, 0, 8640, 4860) this.map.scale.setTo(3, 3) this.mapAbove = this.game.add.sprite(0, 0, 'race') this.game.physics.p2.enable(this.mapAbove, true) this.mapAbove.body.clearShapes() this.mapAbove.body.loadPolygon('physicsData', 'race') this.car = new Car({ game: this.game, x: 3800, y: 3750, asset: 'car' }) this.game.add.existing(this.car) this.game.camera.follow(this.car) } Also i am using this stuff as skeleton - https://github.com/lean/phaser-es6-webpack Could troubles be in incorrect packages? Looking forward for Your reply, Thanks! Link to comment Share on other sites More sharing options...
Lefota Posted September 6, 2017 Author Share Posted September 6, 2017 Fixed that stuff by downgrading to package Phaser: 2.6.3 from phaser-ce: * Link to comment Share on other sites More sharing options...
samid737 Posted September 7, 2017 Share Posted September 7, 2017 #279 Link to comment Share on other sites More sharing options...
Recommended Posts