gzai Posted January 9, 2017 Share Posted January 9, 2017 Hello, How to create water in the bottle, that water have a mass ( weight ) and effect on gravity? Thank you Link to comment Share on other sites More sharing options...
mickeyren Posted January 9, 2017 Share Posted January 9, 2017 you mean like this? https://gamemechanicexplorer.com/#fluid-1 Link to comment Share on other sites More sharing options...
gzai Posted January 9, 2017 Author Share Posted January 9, 2017 yes like that, but can that fluid in the bottle add a mass ( weight ) to the bottle and effect on gravity too? Link to comment Share on other sites More sharing options...
PhasedEvolution Posted January 9, 2017 Share Posted January 9, 2017 12 hours ago, gzai said: yes like that, but can that fluid in the bottle add a mass ( weight ) to the bottle and effect on gravity too? do you mean that the whole liquid contributes to the mass of a container ? a bottle in that case? Link to comment Share on other sites More sharing options...
Penagwin Posted January 9, 2017 Share Posted January 9, 2017 If you implement it based off that source, each droplet just needs to be given a mass, and it all is just placed into a container object. Link to comment Share on other sites More sharing options...
gzai Posted January 15, 2017 Author Share Posted January 15, 2017 hello all, I had a try that source, but I can't fill that water into container object. I have a bottle and a polygon of bottle inside the bottle, when I try to this.fluid.filterArea = this.imgBottle , that water group not fill into polygon of bottle. how to fix that ? and it's that okay to startSystem 2 physics ? pyhsics BOX2D with physics P2JS Thank you preload: function () { this.load.image('bottle', 'images/bottle.png'); this.load.physics('bottlePhysics', 'scripts/bottlePhysics.json'); this.load.image('water', 'images/water.png'); }, create: function () { this.game.physics.startSystem(Phaser.Physics.BOX2D); this.game.physics.box2d.setBoundsToWorld(); this.game.physics.box2d.gravity.y = 1000; this.imgBottle = this.add.sprite( this.game.world.centerX , this.game.world.centerY - 550, 'bottle'); this.imgBottle.anchor.set(0.5); this.game.physics.box2d.enable( this.imgBottle ); this.imgBottle.body.clearFixtures(); this.imgBottle.body.loadPolygon('bottlePhysics', 'bottle', this.imgBottle ); this.game.physics.startSystem(Phaser.Physics.P2JS); this.game.physics.p2.restitution = 0.8; this.game.physics.p2.gravity.y = 1000; this.fluid = this.game.add.group(); for (var i = 0; i < 400; i++) { this.randomX = this.game.rnd.between(0, this.game.width); this.randomY = this.game.rnd.between(0, this.game.height); this.droplet = this.game.add.sprite(this.randomX, this.randomY, 'water'); // Enable physics for the droplet this.game.physics.p2.enable( this.droplet ); this.droplet.body.collideWorldBounds = true; // Add a force that slows down the droplet over time this.droplet.body.damping = 0.3; // This makes the collision body smaller so that the droplets can get // really up close and goopy this.droplet.body.setCircle(this.droplet.width * 0.3); // Add the droplet to the fluid group this.fluid.add( this.droplet ); } this.fluid.filterArea = this.imgBottle; } Link to comment Share on other sites More sharing options...
Recommended Posts