Search the Community

Showing results for tags 'physics'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 493 results

  1. I attach model. And test project (look below). You don't need any server to test it. Just export project zip file and run html in browser! Original exported ToB file is in directory. (I change this file by hand (some lines in code) and seve it in ProjectTest/js/ToB/1/ModelFInish.js. What I would like to achive is to add BoxImpostors on each box/cube/mesh which is named as BoxCollider* Note: There are boxes which have instances !!! When I change code by hand and save in ProjectTest/js/ToB/1/ModelFInish.js. I setup scene in file indexToB.html I add code (for both physics, you can test/try/run any of this but you should comment one of each. scene.enablePhysics( new BABYLON.Vector3(0, -10, 0), new BABYLON.CannonJSPlugin() ); //scene.enablePhysics( new BABYLON.Vector3(0,-10,0), new BABYLON.OimoJSPlugin() ); MAIN PROBLEM HERE IS WHY COLLISION BETWEEN "Ball" AND "BoxCollider.135" DOES NOT WORK! AM I MISSING ANYTHING? WHAT IS THE PROBLEM? CAN ANYBODY TAKE A LOOK AND HELP ME SOLVE THE PROBLEM? IT WILL BE VERY GOOD TO TAKE A LOOK AN TEST IT ALSO INSTANCES AND PHYSICS IMPOSTORS! IF YOU CAN FIND A PROBLEM WHY COLLISION NOT WORKS AND THAN IF YOU CAN CHANGE/FIX CODE OF ToB EXPORTER SO THAT COLLISION DEFINED IN BLENDER FILE AND/OR CHECKCOLLISION CAN BE PROPERLY GENERATED WHEN WE EXPORT FROM .BLENDER TO ToB .JS THAN THIS COULD BE VERY GOOD EXPORTER WITH COLLISIONS FOR BABYLONJS !!! PLEASE LET ME KNOW IF ANYBODY FIND A ERROR IN CODE AND IF AUTOR OF ToB EXPORTER CAN FIX/ADD/REPAIR EXPORTER SO THAT COLLISION/IMPOSTORS CODE IN JS WILL BE SO THAT COLLISION WILL WORKS IN BABYLONJS WHEN WE IMPORT "ModelFInish.initScene(scene);" ToB .js file. What I have change in code by hand! ProjectTest/js/ToB/1/ModelFInish.js Ball: ----- //this.setPhysicsState({ impostor: 1, mass: 1, friction: .5, restitution: 0}); this.physicsImpostor = new BABYLON.PhysicsImpostor( this, BABYLON.PhysicsImpostor.SphereImpostor, { mass : 0.2, friction : 0.5, restitution : 0 }, scene); And Box collider under Ball and its instances BoxCollider.134 or BoxCollider_134 is main box mesh and it have its instances. I also add checkCollisions = true;! I change (this boxes/cubes should be colliders/BoxImpostors with mass 0 (I also add //this.setPhysicsState({ impostor: 2, mass: 0, friction: .5, restitution: 0}); this.checkCollisions = true; this.physicsImpostor = new BABYLON.PhysicsImpostor( this, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0, friction : 0.5, restitution : 0.5 }, scene); and.. // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, --------------------------------------------- var BoxCollider_134 = (function (_super) { __extends(BoxCollider_134, _super); function BoxCollider_134(name, scene, materialsRootDir, source) { _super.call(this, name, scene, null, source, true); if (!materialsRootDir) { materialsRootDir = "./"; } defineMaterials(scene, materialsRootDir); //embedded version check var cloning = source && source !== null; var load = _B.Tools.Now; var geo = 0; var shape = 0; this.position.x = 0; this.position.y = 0; this.position.z = 0; this.rotation.x = 0; this.rotation.y = 0; this.rotation.z = 0; this.scaling.x = 1; this.scaling.y = 1; this.scaling.z = 1; this.id = this.name; this.billboardMode = 0; this.isVisible = false; //always false; evaluated again at bottom this.setEnabled(true); // add below line this.checkCollisions = true; this.receiveShadows = false; this.castShadows = false; if (!scene.isPhysicsEnabled()) { scene.enablePhysics(); } //this.setPhysicsState({ impostor: 2, mass: 0, friction: .5, restitution: 0}); this.checkCollisions = true; this.physicsImpostor = new BABYLON.PhysicsImpostor( this, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0, friction : 0.5, restitution : 0.5 }, scene); if (!cloning){ geo = _B.Tools.Now; this.setVerticesData(_B.VertexBuffer.PositionKind, new Float32Array([ -5,.5,-5,-5,-.5,5,-5,-.5,-5,-5,.5,5,5,-.5,5,-5,-.5,5,5,.5,5,5,-.5,-5,5,-.5,5,5,.5,-5,-5,-.5,-5,5,-.5,-5,5,-.5,5,-5,-.5,-5,-5,-.5,5,-5,.5,5,5,.5,-5 ,5,.5,5,-5,.5,-5,-5,.5,5,-5,-.5,5,-5,.5,5,5,.5,5,5,-.5,5,5,.5,5,5,.5,-5,5,-.5,-5,5,.5,-5,-5,.5,-5,-5,-.5,-5,5,-.5,5,5,-.5,-5,-5,-.5,-5,-5,.5,5 ,-5,.5,-5,5,.5,-5 ]), false); var _i;//indices & affected indices for shapekeys _i = new Uint32Array(36); CONTIG(_i, 0, 0, 35); this.setIndices(_i); this.setVerticesData(_B.VertexBuffer.NormalKind, new Float32Array([ -1,0,0,-1,0,0,-1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0 ,0,1,0,-1,0,0,-1,0,0,-1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,1,0 ,0,1,0,0,1,0 ]), false); geo = (_B.Tools.Now - geo) / 1000; this.subMeshes = []; new _B.SubMesh(0, 0, 36, 0, 36, this); if (scene._selectionOctree) { scene.createOrUpdateSelectionOctree(); } } if (this.postConstruction) this.postConstruction(); load = (_B.Tools.Now - load) / 1000; _B.Tools.Log("defined mesh: " + this.name + (cloning ? " (cloned)" : "") + " completed: " + load.toFixed(2) + ", geometry: " + geo.toFixed(2) + ", skey: " + shape.toFixed(2) + " secs"); if (matLoaded && !_sceneTransitionName){ if (typeof this.grandEntrance == "function") this.grandEntrance(); else makeVisible(this); } else waitingMeshes.push(this); } BoxCollider_134.prototype.dispose = function (doNotRecurse) { _super.prototype.dispose.call(this, doNotRecurse); if (this.skeleton) this.skeleton.dispose(); }; BoxCollider_134.prototype.makeInstances = function (positionOffset) { var instance; instance = this.createInstance("BoxCollider.129"); instance.position.x = 0; instance.position.y = 0; instance.position.z = -10; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); instance.checkCollisions = false; instance = this.createInstance("BoxCollider.100"); instance.position.x = 29.5438; instance.position.y = -2.3742; instance.position.z = 0; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); instance.checkCollisions = false; instance = this.createInstance("BoxCollider.095"); instance.position.x = 29.4404; instance.position.y = 2.5005; instance.position.z = -10.0006; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); instance.checkCollisions = false; instance = this.createInstance("BoxCollider.078"); instance.position.x = -39.0553; instance.position.y = 5.1819; instance.position.z = 0; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); instance.checkCollisions = false; instance = this.createInstance("BoxCollider.073"); instance.position.x = -39.1818; instance.position.y = -4.9811; instance.position.z = -9.9322; instance.rotation.x = 0; instance.rotation.y = 0; instance.rotation.z = 0; instance.scaling.x = 1; instance.scaling.y = 1; instance.scaling.z = 1; // add below two lines instance.checkCollisions = true; instance.physicsImpostor = new BABYLON.PhysicsImpostor( instance, BABYLON.PhysicsImpostor.BoxImpostor, { mass : 0.0, friction : 1, restitution : 0 }, scene); if (positionOffset) instance.position.addInPlace(positionOffset); //instance.checkCollisions = false; instance.checkCollisions = true; }; return BoxCollider_134; })(BABYLON.Mesh); ModelFInish.BoxCollider_134 = BoxCollider_134; @JCPalmer @gryff @Deltakosh @RaananW ProjectTest.zip Model.zip
  2. Hello there! Long time lurker, first time poster here... In the following example: http://www.babylonjs-playground.com/#1NASOD#13 Why does the sphere mesh overlap (or fall slightly into) the box mesh as the box moves upwards? Is there a way to make the sphere not overlap the box as the box moves the sphere upwards?
  3. I have this code: map = GameService.game.add.tilemap('ground'); //map.addTilesetImage('main-tileset', 'tiles'); map.addTilesetImage('base_out_atlas', 'tiles1'); map.addTilesetImage('build_atlas', 'tiles2'); map.addTilesetImage('obj_misk_atlas', 'tiles3'); map.addTilesetImage('terrain_atlas', 'tiles4'); baseLayer1 = map.createLayer('Sub1'); baseLayer1.resizeWorld(); baseLayer2 = map.createLayer('Sub2'); baseLayer2.resizeWorld(); baseLayer3 = map.createLayer('Sub3'); baseLayer3.resizeWorld(); initPlayer(); baseLayer4 = map.createLayer('Super1'); baseLayer4.resizeWorld(); baseLayer5 = map.createLayer('Super2'); baseLayer5.resizeWorld(); baseLayer6 = map.createLayer('Super3'); baseLayer6.resizeWorld(); collisionBodies = GameService.game.physics.p2.convertCollisionObjects(map, 'Collisions'); I'm sure you can see what it's doing, but basically, I create a few layers, initialize my player, create a few more layers, and then convert my Tiled object layer into collision objects. My question is, what do I do with `collisionBodies`? Will `convertCollisionObjects` put the objects onto the map? It should by default, right? Does `convertCollisionObjects` give my objects bodies? I think they do, but my player is not stopping when he touches them. Am I supposed to write a function to handle what actually happens when they collide? Sorry for all the questions, I can't find an example of this in use in the documentation.
  4. This is version 2 of my game Descensus from several years ago. It's a simple but difficult 2D physics game in which you have to guide the ball to the ground by swiping bars on screen, bouncing it around spinning saws and off moving terrain objects. There's a time limit to reach each 100m stage, and you can use terrain objects to your advantage as well. It was written using the physics library p2.js and the rendering library Pixi.js. I wrote in in TypeScript, bundled with Webpack, developed using Visual Studio Code. The Android version was packaged using the cloud build system Monaca, bundling the Crosswalk webview (hence the relatively large APK size). It doesn't use any PhoneGap APIs - the sound is all HTML5 Audio. I did most of the testing on desktop so I know that it works nicely with both mouse and touch. I have put an online version (with sound disabled) at http://booleanoperations.com/descensus2 Play Store link: https://play.google.com/store/apps/details?id=com.booleanoperations.descensus2 Video: https://www.youtube.com/watch?v=9BWii8aokbQ
  5. I am using CannonJS with BabylonJS, and I want to make a stack of 3 boxes, all the same size, but when I do, they slowly slide around until the stack topples. I have tried setting restitution to 0, and various values for gravity, mass, and friction, and regardless, the stack always topples itself undesirably. I only want them to topple when rammed with some other object. How can I achieve this?
  6. Is it possible to add a physics impostor to a free camera with cannon.js that allows it to collide with rigid bodies just like any other mesh that has a physics impostor? I also need the free camera to maintain the standard keyboard/mouse controls.
  7. I'm trying to figure out how to make a projectile pass THROUGH certain objects while making contact with others. I'm also having the issue where my projectile is created dynamically so I can't stick in a event listener in the registerBeforeRender() function because they don't exist at the time that function is called. Basically, I want to be able to shoot enemies in my game, while not shooting allies. I'm also having an issue where I can't seem to get rotation coordinates of my object. I can get the coordinates but when I check mesh.rotation() I always see 0, 0, 0 even when I change it with a event listener...
  8. I am new to 3D game dev, and I'm wondering how to make a triangular prism that a sphere could roll down. I think I'm missing something huge, because physics libraries only seem to support the most basic geometries, excluding triangular prisms and other important shapes. Could someone please point me to some resources or explain how to deal with physical interactions between more complicated shapes? I notice that BabylonJS makes it easy to create lots of neat meshes, however, I'm missing how to simulate their shapes on the CannonJS side of things. I want to make a game where the player controls a sphere by rolling it around various scenes, but it just doesn't seem possible using only spheres and boxes, for example.
  9. Hello, I am using Arcade Physics to do a very simple test. But I could not figure out what goes wrong. I have a player, a ground, a ledge, and a block. Everything is enabled with Arcade Physics. The player can move horizontally and "push" the block down the ledge. Its good. But when the player "jump on" the block, the block will "go through" the edge and fall down to the ground. Its not what I want. When the block is on the ground, and the player "jump on" the block. It will also "go through" the ground. Its not what I want. The block should be "on the ground", and should NOT "go through the ground". My English is poor, please see the following videos for what I mean. http://recordit.co/9PT0X6o4Qu When turn on game.debug.body(), it looks like this http://recordit.co/WXEolzfO2G The code is very simple. player: this.player = game.add.sprite(x, y, 'dude'); game.physics.arcade.enable(this.player); this.player.body.gravity.y = 2000; this.player.body.collideWorldBounds = true; Ground and ledge: this.platforms = game.add.group(); this.platforms.enableBody = true; let ground = this.platforms.create(0, game.world.height - 24, 'ground'); ground.body.immovable = true; ground = this.platforms.create(400, game.world.height - 24, 'ground'); ground.body.immovable = true; ground = this.platforms.create(-100, 350, 'ground'); ground.body.immovable = true; Block this.block = game.add.sprite(270, 100, 'ground'); game.physics.arcade.enable(this.block); this.block.body.gravity.y = 2000; Update() game.physics.arcade.collide(this.block, this.platforms); game.physics.arcade.collide(this.block, this.player); game.physics.arcade.collide(this.player, this.platforms); Please tell me what I did wrong. Thanks you very much.
  10. Hi everyone, I am new to Phaser framework and it's great! I have made a lot of progress on this Street Fighter game I am doing. A little background of my problem: I have my code set up that when I press W (Medium Punch), I increase the width of the sprite by via setRectangle playerKen.body.setRectangle(70, 80, -18); once I expanded the hitbox , I play the sprite, then set the width back to its original size once the animation has finished playing: kenAnimation = playerKen.animations.play('standingMediumPunch', 10, false).onComplete.add(function () { //reset the graphics back playerKen.body.setRectangle(35, 80, -18); playerKen.body.setCollisionGroup(kenCollisionGroup); playerKen.body.collides(mBisonCollisionGroup, hitEnemy, this); kenAttacking = false; playerKen.body.velocity.x = 0; playerKen.animations.play('standing', 7, true); playerKen.body.static = false; //console.log('punching'); }, this); I have also programmed the AI too, won't get into that. But my issue is the overlapping hitboxes. See the attached photo... When a situation like this occurs when I am punching and the AI is punching as well, the health of the player and the AI does not decrease. I looked into https://phaser.io/examples/v2/sprites/overlap-without-physics but the getBounds() method only gets the width of the sprite, not the hitbox. How can I see whether the two hitboxes have intersected? By the way, I am using p2 physics. Thanks a bunch!
  11. Does Debug/Inspector has opstion to show colliders in scene? Is there any plan to add this options to see how meshe's colliders are aligned? Or is there any javascript function which can enable or allow this capability? Greetings Ian
  12. I have a mesh imported from .babylon file, and it has its animations. I put MeshImpostor in, expecting it to update with the animation, but it's not. It seems like it uses the first frame as the reference to the collision detection. Is there any way to update it? Code is something like this: var mesh = scene.meshes[0]; mesh.physicsImpostor = new BABYLON.PhysicsImpostor(mesh, BABYLON.PhysicsImpostor.MeshImpostor); //I tried to force it update it too, but doesn't seem to work. function update() { mesh.physicsImpostor.forceUpdate(); }
  13. I have a sprite of a character moving and I'm trying to apply physics collide on it that when it hits a rock for example health is decreased. I managed to achieve collision but as rectangular shape of the image, what I want to achieve is the collision happens on the boundaries of the character itself. I used PhysicsEditor to generate the JSON file, but I'm still not sure how to use it to achieve pixel perfect collision. Any thoughts?
  14. Hi, have a problem with parenting physics objects together. Here an easy playground: http://www.babylonjs-playground.com/#AF886#1 Why is b dont collide with the ground too like the parent? I want both collide the ground and behave like one. Is it a bug?
  15. Hi, I'm working on a game called HaxArena that is available here: http://eu.haxarena.com/ | http://us.haxarena.com/ | http://eu2.haxarena.com/ | http://us2.haxarena.com/ and right now I'm trying to add Client Side Prediction based on the source code from http://www.gabrielgambetta.com/fpm_live.html. At the beginning I improved that demo by adding another dimension http://hax.droppages.com/ and now I'm trying to integrate that example with Matter.JS but I somehow can't make it work correctly e.g. I see some kind of rubber banding or the player starts moving faster and faster with every frame even though I don't press any buttons. There are 2 functions available: Matter.Engine.update(engine, [delta=16.666], [correction=1]) - right now I'm using only this one on the server while I still don't have any Client Side Prediction; it's responsible for movement of all bodies and collisions Matter.Body.update(body, deltaTime, timeScale, correction) - I'm trying to use it in the applyInput method of the Entity class var Entity = function() { this.x = 0; this.speed = 2; // units/s } // Apply user's input to this entity. Entity.prototype.applyInput = function(input) { this.x += input.press_time*this.speed; } I also tried changing some parts of this function: Client.prototype.processServerMessages = function() { while (true) { var message = this.network.receive(); if (!message) { break; } // World state is a list of entity states. for (var i = 0; i < message.length; i++) { var state = message[i]; if (state.entity_id == this.entity_id) { // Got the position of this client's entity. if (!this.entity) { // If this is the first server update, create a local entity. this.entity = new Entity(); } // Set the position sent by the server. this.entity.x = state.position; if (server_reconciliation) { // Server Reconciliation. Re-apply all the inputs not yet processed by // the server. var j = 0; while (j < this.pending_inputs.length) { var input = this.pending_inputs[j]; if (input.input_sequence_number <= state.last_processed_input) { // Already processed. Its effect is already taken into account // into the world update we just got, so we can drop it. this.pending_inputs.splice(j, 1); } else { // Not processed by the server yet. Re-apply it. this.entity.applyInput(input); j++; } } } else { // Reconciliation is disabled, so drop all the saved inputs. this.pending_inputs = []; } } else { // TO DO: add support for rendering other entities. } } } Something like: var isSimulation = true this.entity.applyInput(input, isSimulation); and then using a fake / shadow body to apply an input and setting the final position of that fake body to the real body to avoid the rubber banding problem. I will be really helpful if anyone gives me some advice or an idea of how to deal with these problems.
  16. Hello! I am the P2 physics. I have a sprite scaled. My problem is that the polygon loaded to the sprite does not scale with it. It is possible to scale the polygon?
  17. Hi, i'm curenttly working on a multiplayer game build with Phaser 2.6.x, and for like 2 weeks i'm strugaling to initialize on node.js only the Phaser Arcade Physics, but i can't find how. Anybody ever tried to run Arcade Physics by his own ?
  18. Play at: Space Captain vs Mega Robots
  19. Hi, I would like to modify time scale in a 2D physics engine. I searched about it, and matter.js seems to permit timescale modification. In addition, i would like to set 'different timescales' for different bodies (as example: 2 object fall, one will be set to timescale:1 and the other timescale:0.5. So this last one will fall 2x slowly) It sound nonsense, but is there a trick to do it? I thouth about saving positions on last step, and compare them to the new one, then replacing them with a homothety value relative to the timescale. But there is a lot of cases that this can't handle Any sugestions? Thanks
  20. I have a "bouncy" ball that will hit a fixed world surface and act as you would expect. However, when the world moves upward to the ball, the bouncing slows and if the world is moving fast enough, the bouncing stops completely and the ball "hugs" the world surface. What I'd like to happen is to transfer the upward velocity of the world to the ball. So if the ball is falling and the world is moving up, I want the ball to act as if it has been hit by a swinging baseball bat. Right now, the ball acts as if it has been contacted by a magnet. I just can't seem to find the right properties to make this type of collision happen. Thanks! And thank you to all who have asked and answered the many questions I had while I was building my game. Such a great resource!
  21. Hi, I want to make a pinball game with phaser and p2 js physics. I have a probleme with flips. To make the rotation movement, i must to change anchor to 0,0 with : this.flipGauche.anchor.set(0); but with this the sprite the anchor'sprite change but no the body https://postimg.org/image/76jmynhx5/
  22. Hi @all, Is there a problem with the HeightmapImpostor? In my test application dont work the pyhsics anymore. The player and other objects fall now through the ground. let groundFHM = BABYLON.Mesh.CreateGroundFromHeightMap("groundFHM", "textures/heightMap.png", 100, 100, 100, 0, 10, scene, false, function () { ... groundFHM.physicsImpostor = new BABYLON.PhysicsImpostor(groundFHM, BABYLON.PhysicsImpostor.HeightmapImpostor, { mass: 0, friction: 0.2,restitution: 0.3 }, scene); }); In this Demo from @Wingnut http://www.babylonjs-playground.com/#1RKZXB#6 works the physics also not correct at all. Edit: In my older babylon.js alpha version this works by the way
  23. I made a pretty good Frogger clone using PhaserJS, but when refactoring the code, I ran into a very, very strange problem. My vehicles currently have a velocity of 200. When Frogger collides with one of them, that vehicle's velocity drops in half. Frogger also gains the velocity of that object. In update this.game.physics.arcade.collide(frogger, vehicles, this.loseLife); Here's my vehicles code objects.forEach(o => this.game.physics.arcade.enable(o)); [normalCar1, normalCar2, normalCar3, specialVehicle1, specialVehicle2, specialVehicle3, emergencyVehicle1, emergencyVehicle2, emergencyVehicle3].forEach(function(object) { object.body.velocity.x = object.direction == 'right' ? 200 : -200; }); Here is my loseLife() function loseLife: function() { /*switch (frogger.health) { case 5: lifeFive.destroy(); break; case 4: lifeFour.destroy(); break; case 3: lifeThree.destroy(); break; case 2: lifeTwo.destroy(); break; case 1: lifeOne.destroy(); break; }*/ frogger.damage(1); gameState.resetPosition(); gameState.resetRows(); /*if (!frogger.alive) { clearInterval(sinkLillies); game.state.start('gameover'); }*/ }, The important method here is resetPosition() which moves Frogger back to the starting position resetPosition: function() { frogger.alpha = 0; frogger.x = this.game.world.centerX; frogger.y = this.game.world.height - 18; game.time.events.add(1000, function() { this.game.timer = 50000; frogger.alpha = 1; }, this); }, The important thing here is that I do not specify that I want the velocity to increase Hopefully, a video will make it easier to understand https://webmshare.com/DmoAQ Edit: A temporary working solution I was able to "solve" this by adding this line in the resetPosition() function frogger.body.velocity.x = 0; And to remove that weird behavior of the car slowing down objects.forEach(function(object) { this.game.physics.arcade.enable(object); object.body.immovable = true; }); This is a hack though. I shouldn't have to explicitly add these lines, because collisions shouldn't cause this behavior in the first place.
  24. How to use P2 Physics with each layer object? Code this.saws = this.game.add.group(); this.saws.enableBody = true; this.map.createFromObjects('saws', 4, 'saw', 0, true, false, this.saws); this.saws.forEach(function(saw) { saw.body.clearShapes(); saw.body.loadPolygon('physicsData', 'saw'); });
  25. hi guys I found out low frame rate slow down physics update too. (in arcade & p2 physics) for instance, in same gravity settings, results are different depending on frame rate. (body hits the ground more faster in the higher frame rate environment) I don't know much about game engine or framework, but I think it is more appropriate that physics updates by elapsed time, not by frame count. I came to think Phaser is really well made framework after looking into examples on official websites, and I don't think Phaser creator didn't think about this issue. I googled about this issue, but couldn't find any answers that suit on me. (probably because of my poor english) I would be appreciated if you give me any clue.