Bartuken Posted October 21, 2017 Share Posted October 21, 2017 Hello! In Phaser ( particularly Phaser CE ) I can't find something like Wind Resistance for objects. And start thinking how to implement my own version: create(){ game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.gravity.y = 100; this.car = game.add.sprite(32, 32, "car"); game.physics.p2.enable(this.car,false); this.car.body.windResistance = 0.4; } update(){ if(this.car.body.windResistance && this.car.body.velocity.y > this.car.body.windResistance ){ this.car.body.velocity.y-= this.car.body.windResistance; } } With this I can't use big numbers for windResistance, only between 0 and 1. What do you guys think?? Link to comment Share on other sites More sharing options...
samid737 Posted October 21, 2017 Share Posted October 21, 2017 For different gravities, you can set gravity scale on each sprite:https://phaser.io/examples/v2/p2-physics/gravity-scale You can use the damping property to introduce drag/windresistance on each sprite. You can use values higher than one if your looking for a threshold value for velocity. But if you subtract the same number in update things might go wrong. Also the if statement does not look like it will work. Umz and Bartuken 1 1 Link to comment Share on other sites More sharing options...
Bartuken Posted October 21, 2017 Author Share Posted October 21, 2017 Awesome! Thx for that. I Will implement this in my game. Link to comment Share on other sites More sharing options...
Recommended Posts