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 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 628 results

  1. Hi, im trying to make a top-down game where (among other things) you can push around boxes. I'd like it to be very simple in the sense that the player always moves with constant speed, pushing boxes shouldn't slow him down and boxes should stop immediately once they're not being pushed anymore. Can this be achieved with arcade physics? The biggest issue however is when the player pushes multiple boxes against the world border. Once there is no room anymore, the player can still move in that direction and push boxes 'into' other boxes. Is it possible that all entities always act solid at all times, so that when the player pushes multiple boxes in a direction where there is no room, he simply doesn't move any further? Below is what i've tried so far in the sandbox: var config = { type: Phaser.AUTO, width: 800, height: 600, parent: 'phaser-example', physics: { default: 'arcade', arcade: { debug: true } }, scene: { preload: preload, create: create, update: update }, player_speed: 150 }; var game = new Phaser.Game(config); var player; var group; var cursors; function preload () { this.load.image('block', 'assets/sprites/block.png'); } function create () { cursors = this.input.keyboard.createCursorKeys(); group = this.physics.add.group({ dragX: 500, dragY: 500, collideWorldBounds: true }); var block1 = group.create(100, 300, 'block'); var block2 = group.create(200, 300, 'block'); var block3 = group.create(300, 300, 'block'); var block4 = group.create(400, 300, 'block'); var block4 = group.create(500, 300, 'block'); player = this.physics.add.sprite(500, 500, 'block'); this.physics.add.collider(group); this.physics.add.collider(player, group); } function update() { player.setVelocity(0); if (cursors.left.isDown && !cursors.right.isDown){ player.setVelocityX(-config.player_speed); } if (cursors.right.isDown && !cursors.left.isDown) { player.setVelocityX(config.player_speed); } if (cursors.up.isDown && !cursors.down.isDown){ player.setVelocityY(-config.player_speed); } if (cursors.down.isDown && !cursors.up.isDown) { player.setVelocityY(config.player_speed); } } Thanks in advance!
  2. hg_tg

    Recursive Collision

    Hi all, I have been stuck for some time on procedurally generating levels for my game. As it stands, I have created rooms in a confined space but most of them overlap. Although this is expected, I can't find a way to separate them. My attempts have been centered around physics collisions, but I have failed hard. Here is my current code: Level.prototype.separate = function() { //For Convenince sake var arcade = this.game.physics.arcade, rooms = this.rooms; for ( var i = 0; i < rooms.length - 1; i++ ) { while ( arcade.intersects( rooms[ i ], rooms[ i + 1 ] ) ) { arcade.collide( rooms[ i ], rooms[ i + 1 ] ); } } //For testing purposes this.displayLevel(); }, Level.prototype.create = function() { this.game.physics.arcade.enable( this.rooms ); this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; //Gets coordinates and dimensions for Rooms and creates them. this.createLevel(); console.log( "Level State Completed" ); //this.game.state.start( 'InGameState' ); }, Level.prototype.update = function() { this.separate(); } This doesn't work. It results in an infinite loop. I have tried used Arcade's overlap as well. The issues I have had boil down to these two questions: 1. How can I test for individual room collisions when they sit in an array together? 2. When two rooms collide with one another, one or both of the rooms may still be colliding with other rooms. However, Arcade's collide method isn't recursive, and throwing the separate function into update might not guarantee the rooms be separated and hurts performance. Does anyone have any ideas or potential solutions to this?
  3. Probably some easy question... but I've been struggling too long with the math. Does anybody know how to compute the Linear Velocity (world space) of a Circus Cannon Ball based on the Cannon Tube mesh orientation? In this case I use positive Y axis of cannon tube as 'forward', but in general I use the local Z axis as forward (to adhere to the definitions of BABYLON.Vector3.Forward() etc.). Once I know how to dynamically compute the (normalized) direction of the tube, I can then scale this vector with the cannon's shooting power (e.g. longer fire button press results in farther shooting). And add some random vector noise to make easy ball have a slightly different path each time. Please note that the tube is a child mesh on purpose so the orientation needs to be translated to world first. Here's the playground so far: http://playground.babylonjs.com/#R8ZH46 The solution to this question will probably be useful for anyone else who is creating some kind of ballistic shooter game (not first person). I noticed that all physics vectors are in world space only so therefore I am looking for these kind of transformations to roll up local mesh orientation to world physics direction. Thanks Q P.S. The cannon is set to auto-fire but you can use SPACE for fire as well, and [ and ] to turn the cannon.
  4. xtreemze

    Defend

    Hi everyone, Been away for a while but I've kept practicing with Babylon. This is at a prototype phase with no 3d/sound/artwork. Just pure javascript code for now. Trying to get the mechanics working properly first. One question I have is how the projectile rotationQuaternion is cloned. It seems to follow the lookAt() quaternion from the origin tower even after the quaternion is cloned. How can I ensure that the rotationQuaternion is not linked to the original quaternion it is taken from? This causes problems when a tower shoots a projectile and then rotates to target another enemy. The previously mentioned projectile rotates in midair still copying the rotation of the tower. Here's the relevant code taken from line 53 of https://github.com/xtreemze/defend/blob/master/src/js/main/projectiles.ts const clonedRotation = originMesh.rotationQuaternion.clone(); clonedRotation.normalize(); projectile.rotationQuaternion.copyFrom(clonedRotation); Comments, questions are welcome! The project is hosted here with open source: https://github.com/xtreemze/defend View the project here: https://xtreemze.github.io/defend
  5. So I am working on my just general knowledge of how phaser works, I have only done two tutorials. But I think I have a decent grasp on it so far. But I am running into a little problem, I am trying to use the Follower object, so that I don't have to create the vec2 and attach it, but I don't seem to understand the documentation or what it means by "If this Game Object is enabled for physics then this property will contain a reference to a Physics Body." I have scoured the docs for hours. I see how to 'enable' in arcade physics but I cannot find any reference to how with impact physics. I am able to create a body object, and assign it to the game object, as well as assign the the game object to the body, but they do not move in tandem. in fact the body does not move at all. P.S. This is not the only bug, when converting from matter.js to impact.js physics my logic on pausing player movement when the dialog modal broke. but one problem at a time.. P.P.S I know its not the best code //SHIVA path3 = new Phaser.Curves.Path(550, 450); path3.lineTo(450, 450); path3.lineTo(450, 505); path3.lineTo(550, 505); path3.lineTo(550, 450); path3.lineTo(450, 450); shiva = this.add.follower(path3, 550, 450, 'shiva'); //Phaser.GameObjects.BuildGameObject(this, Phaser.GameObjects.PathFollower) //this.game.physics.enable(shiva, impact); shivaBody = this.impact.add.body(550, 450, 16, 12); //TRYING DIFFERENT WAS TO SET BODY //shivaBody.setOffset(550, 450, 16, 12); shiva.body = shivaBody; shivaBody.setGameObject(shiva); shiva.name = "shiva"; shiva.setRotation(); shiva.depth = 30; //ALT WAY TO GET NAME //shiva.name = "shiva"; shiva.setData(npc, true); shiva.setData("name", "shiva"); npcBodies[2] = shivaBody; npcs.add(shiva); shiva.startFollow({ ease: 'Linear', duration:6000, yoyo:true, repeat: -1, _delay: 200, delay: 100 }); P.P.P.S I also tried this.physics.world.enable(shiva); this.impact.world.enable(shiva); dialog_plugin.js game.js index.html city.json
  6. For no good reason I was thinking about physics engines and came across this. As I was looking for a new challenge I took a look and as BitOfGold said the API is horrible but though I would give it a go. I took this example and had a go at making it work with Babylon. Never having worked with 'workers' before I had a go at doing a test with a direct implementation with Babylon.js which is here and if anyone is interested the code is at github. Very early days but slowly over the next year I will have a go at seeing what is possible and if getting somewhere will see whether it would make a good extension with added documentation. As a very amateur coder however I have a lot to learn for example how do I use ammo.js without enclosing everything in Ammo().then(function(Ammo) { }) Anyone else interested in seeing what is possible with Ammo.js and Babylon.js the let me know.
  7. Hi all, I have been playing with Babylon in an attempt to create some browser-living simulations, e.g. "interactive permanent magnet electricity generator to help in the visualization of flux". The syntactic feel, playground examples, and this community, everything has felt awesome. But, I have really struggled in (story to let you seniors have a sense of my level): 1. creating a 3D vector field (my grid-based euler-integral curve drawing algorithm was crashing the browser; got it partially working by copying starting points approach from here: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/streamplot.py 2. I am having trouble in creating a simple fixed viewplane and fixed camera 2D view. (This is noob, but confidence denting, if I may say that) So, my questions are: 1. Is Babylon the right tool to create educational content inspired physics simulations, and lightweight games (user interactions + scoring + webapp data bindings ) around it. Or, is it an overkill? Is something like p5.js more apt for my purpose? 2. Should I be using phaser for (strictly) 2D environments? If I should, would using Babylon and phaser hurt code (e.g. say having a single script file for air drag force )? 3. Is "Learning Babylon" book a right start (it's lagging in the version support)? I am kind of lost in the jungle; please bear with me not being to the point. And I hope this forum will be kind enough as usual to point me to the right resources. P.S. I am willing to pay for book/resources, if you have anything in mind. Also, I would prefer "getting in the run" asap, if that's possible. Thank you all!
  8. Ninja.io is a fast paced, 2D multiplayer shooter inspired by games like Soldat, Unreal Tournament and N-game. Currently implemented game modes include Capture the Flag and Deathmatch. It uses the Box2D physics engine to enable convincing rigid body simulation. Players can make various moves including backflips, rolls, proning, running, flying and crouching. The game is still under active development and I'm willing to devote a great deal of time to finishing this project. I've made a test server available and you can join it by following these steps: - Go to ninja.io - Play as Guest - Enter a username - Join CTF or Deathmatch. - Select primary and/or secondary weapon Press H to display table of controls. Decrease the size of the browser window in case it runs slow. I've noticed that some laptops and older systems have trouble maintaining adequate fps. It is currently not possible to register a username, but I've been making progress on an account and highscore system. The game server is currently located in Europe. I plan on running additional servers on other continents and for the site to serve as a gateway to the nearest game server when players join in order to minimize latency. Any thoughts, feedback or suggestions would be much appreciated! Thanks. Edit - 15-12-2017: New version! Sound effects have finally been added, weapons & items have been updated & tweaked, libraries have been updated and many improvements have been made along with numerous bugfixes. I'm currently finishing the implementation of the account system and I'm working on several new maps. More updates will follow soon!
  9. Hello, I'm a web programmer with 3 years of experience (currently a senior developer). I've always been a fan of videogames and now I'm starting learning game development just for fun. Like in any type of development , you always face problems and learn of those. Sharing is the strongest tool to learn, you help other people to prevent/fix mistakes and they help you. What am I looking for?: People like me that is learning to develop games and want to meet other people to make games with them, share experiences, ask&answer questions. How will we organize? I have experience managing large Telegram groups and also creating bots for groups. It is a good starting point since most of the people always carry the phone everywhere and also has a web/desktop application, also Telegram offers us a direct communication without compromising your privacy (you don't need to give real info or phone number to the rest of the group). If we start growing, we can just move to another platform you want (Discord, Slack, whatever is of your preference). Do you have any project scheduled? Yes, I want to build a fun roguelike, here is my current roadmap of the game: I am an artist, can I join? Sure! I'm sure you can learn from us and we can learn from you, Keep in mind that sound artists, level designers, programmers.. work together and they need to understand all the other positions to work properly. Of course this is a flexible diagram, I don't do this as my job and I don't have any deadlines, creating a roadmap just helps me with organization so I don't start wrongly (which with end even worse :P). Have in mind that my only goal is just learning, I'm not in a rush to make money or finding a job Just feel free to contact me if you want to join or if you doesn't like something of my post.
  10. digitsensitive

    Restart Scene: Collider Destroy

    Hello! I was wondering if this is the correct approach, regarding management of the collider when restarting a scene. I have added this collider in my scene: this.physics.add.collider( this.traps, this.player, this.playerTrap, null, this ); I restart the scene as soon as this collision happens in the playerTrap() function: private playerTrap(): void { this.player.setAlive(false); this.cleanScene(); this.scene.start("GameScene"); } The cleanScene(): private cleanScene(): void { this.physics.destroy(); } Without the cleanScene() function he restarts the scene infinitely. I always thought that when using this.scene.start he auto cleans everything and reboots.
  11. Hey everyone, I looked around for details on this but I am trying to determine the difference between the Physic types: Arcade, Impact, Matter to see what would be best for my type of game or to experiment with. I read in the Dev blogs that "Arcade" was meant for very simple physics in a game, while somewhere else I read that "Matter" was meant for debugging... I would like to know what the real differences are and which would make the most sense for a given game type. Does anyone know what the differences between the Physic types are? Thanks!!!
  12. I'm trying to make a Mario styled platformer, and i'm running into a problem where the jumping animation is overridden by the walking animation when pressing the up and right(or left) arrow keys together. Here's what i have in regards of the update and playing the animations. The character sprite is loaded as a spritesheet if it makes a difference. if(this.cursors.right.isDown){ this.mario.play('walk', true); this.mario.flipX = false; this.mario.body.setVelocityX(500); } else if(this.cursors.left.isDown){ this.mario.play('walk', true); this.mario.flipX = true; this.mario.body.setVelocityX(-500); } else{ if(this.mario.body.onFloor()){ this.mario.play('stand'); }else { this.mario.play('jumping'); } this.mario.body.setVelocityX(0); } if(this.cursors.up.isDown && this.mario.body.onFloor()){ //this.mario.play('jumping'); this.mario.body.setVelocityY(-600); }
  13. timetocode

    NullEngine and oimo

    I'm attempting to use NullEngine in node.js as a component of the server side simulation for a multiplayer game. When using *just* NullEngine + nengi.js (a multiplayer engine) mesh intersection and rays work great. I can get somewhere in the realm of 50-150 ccu (that's players, not NPCs). The performance is really awesome. Now I'm trying to get some more advanced physics in place. However when I attempt to include OimoJSPlugin on the serverside I get " TypeError: Cannot read property 'World' of undefined " const BABYLON = require('babylonjs') let engine = new BABYLON.NullEngine() let scene = new BABYLON.Scene(engine) let camera = new BABYLON.ArcRotateCamera('Camera', 0, 0.8, 100, BABYLON.Vector3.Zero(), scene) scene.enablePhysics(null, new BABYLON.OimoJSPlugin()) That last line there is the one that throws the error. Any idea what I'm doing wrong? I also get a warning that 'oimo' module cannot be found (related, I presume?). I setup babylon via `npm install babylonjs` (as opposed to downloading something) and the version is 3.2.0. Thanks for reading! And BJS + NullEngine is a dream come true!
  14. syed samoon

    hoverboard setup

    Hi, i'm newbie. i need a help to setup hoverboard. The player should have physics engine and the same time the player always maintain a some gap between the board and track.
  15. this.game.physics.startSystem(Phaser.Physics.P2JS); this.game.physics.p2.setImpactEvents(true); var wallCollisionGroup = this.game.physics.p2.createCollisionGroup(); var playerCollisionGroup = this.game.physics.p2.createCollisionGroup(); var doorCollisionGroup = this.game.physics.p2.createCollisionGroup(); this.game.physics.p2.updateBoundsCollisionGroup(); // I've created all the necessary collisions as in expamle: https://phaser.io/examples/v2/p2-physics/collision-groups and it works perfect. player.body.collides(wallCollisionGroup); player.body.collides(doorCollisionGroup, wrongDoor, this); cursors = this.game.input.keyboard.createCursorKeys(); } wrongDoor() { player.body.velocity.x = 0; player.body.velocity.y = 0; //player.body.setZeroVelocity(); //player.body.velocity.x = -20000; //player.body.velocity.y = -20000; //player.body.static = true; result = 'You last hit: The wall :)'; this.game.displayDialogLine('Message', 'text'); } update() { player.body.velocity.x = 0; player.body.velocity.y = 0; if (cursors.left.isDown) { player.body.velocity.x = -300; } else if (cursors.right.isDown) { player.body.velocity.x = 300; } if (cursors.up.isDown) { player.body.velocity.y = -300; } else if (cursors.down.isDown) { player.body.velocity.y = 300; } } Hello. I'm making a game where player have to reach the right door and created all the necessary collisions and it works almost perfect, except the call back function wrongDoor. I want to create a dialog line when player collides wrong door and make his velocity = 0 while dialog line is on screen, but I can't. Every time player colldes the door dialog line displays on screen but the player sprite still moves. How can I make him stop on collision with door? All the //commented stuff I've tried and it didn't help. I tried to add this function in Update function but it triggers wrongDoor all the time and displays dialog line again and again from the start of the game. I've tried set velocity = -20000 but it doesn't set -20000 velocity, like it doesn't see the player. On screenshots I press up and right buttons so character moves up and right after wrongDoor triggers.
  16. Hi, I am trying to make a goalkeeper game, which require goalkeeper mesh body to be able to "block" any football that hit toward him. The best would be the mesh collider that represent the goalkeeper to be reasonably precise while not being overkill, so I created boxes, set their physics imposter, and attach them to each bone. which look like this: http://www.babylonjs-playground.com/#SRR6Y2#1 however, I don't know how to make each box collidable to the falling sphere, did I miss anything, or does it require more complex way of implementation?
  17. Hello, I am working on a project where i can drag an object in X-direction only(like in a abacus). Is it possible to drag objects in one direction only? I created a simple task where i can move two objects with mouse (link here). The issue is that objects are pushing inside each other if i drag one object to another. I need them to be hard like diamond. Can i achieve that with p2 js or i have to use box2d plugin (like here). Also is box2d will be availabe in phaser v3. Thanks
  18. IKStreamIvo

    Parenting to sprites

    I have a sprite using (arcade) physics and I'm setting velocity to move around. When the player overlaps with a weapon, you can press a key to pick it up. I want the gun to be at an offset-ed position to the player and follow it around.. I thought parenting it was the easiest, but I can't figure out how to do it. Can anyone help me with this? 😃
  19. I was noodling around and trying to create groups of game objects that had 3 sprites that were cropped from one image. Similar to a 3-panel round cornered web button. The reason for this structure is I need variable width with the outer left and right images being fixed. But I also need it to be a game object with physics and collisions. I tried adding tileSprite to physics to make this, but it did not work with physics. ("Error: Not a function") this.blockLeftCap = this.physics.add.tileSprite(100,100,44,43,'button-001'); In the end I can just cut solo images individually, and then add as sprites to physics with no issue: this.blockLeftCap = this.physics.add.sprite(100,100,'btn-001-cap-left'); Since I can do this other ways it is no big deal. But I did like the way tileSprite allowed for easily adjustment of the image cropping. Just wanted to double check if I was missing something. Thanks, Matt
  20. Hello, I am new to phaser and trying to learn phaser 3. I need a revolute constriant for a project. There are examples for phaser 2 using box2d and p2physics, but they wont work in phaser 3. I tried looking that in documentation but i don't think it is complete yet. Can anybody please tell me how to create a revolute constraint (or pin joint) in phaser 3 (preferably in matter js). Thanks
  21. Hi Guys! I haven't been active here for quite some time and haven't done anything with Babylon.JS for quite a long time. But after checking out the changelogs, I saw that we can now run Babylon.js Server Side, how awesome is that! So I had to squeeze in some time and implement a proof of concept multiplayer simulation with Client and Server side physics engine. It's quite basic. The Client can control a ball by spinning it forward or backward (with W and S). By changing the camera angle (with A and D) you can change the direction of the impulse. With Space you can jump around. To check out how it behaves with multiple players you can either ask someone to also visit the site at the same time or just open a new tab in your browser. Technical it is rather simple. Server and Client communicate via Websockets. The client applies impulses to it's ball, these parameters for these impulses are sent to the server. The server applies these also and keeps the state for the whole world up to date. Each render loop the server sends the current state to all the clients (ideally 60 Hz). The clients then correct the position, direction and velocity of all objects including their own ball if needed. I haven't tried it out with higher delays, but I would suspect the result will be quite "jumpy". Interpolation for correction and prediction of movement is not (yet) implemented. Added Server Update Rate and Ping to see lags and delay in perspective to these metrics. Here is the code: https://github.com/j-o-d-o/multiplayer-babylon-js-game Here is the Demo: http://185.82.21.82:8700/ Here is a great article about Server-Client Game Networking techniques: http://www.gabrielgambetta.com/client-server-game-architecture.html which was somewhat the motivation to implement this proof of concept.
  22. I've published the first version of my grid-based physics plugin for Phaser 3 (a port and improvement from the Phaser 2 version). It makes it easy to create a game where the movement is restricted to tiles or a grid and comes with helpful built-in features such as a system for pushing objects or walking on one-direction tiles. I'm making the plugin to use it in a RPG I'm developing but it's suitable for everything from Sokoban-like games to Rouge-like. However, the development of the plugin will be focused to add features I need and fixing bugs that affect my game. Let me know if you use the plugin and feel that stuff is missing or if you run into issues. I won't be adding stuff just for the sake of the plugin unless there is a demand. 1. Testing a bridge and tiles will collidable borders. 2. Testing one-way collision (and I got stuck). 3. Turn-based mode with smooth animations. Multiple bodies getting pushed. DEMO http://metroid.niklasberg.se/P3GridPhysics/ (Use dat.gui to toggle turn-based mode, maximum number of bodies the player can push, velocity and more) Github: https://github.com/nkholski/phaser-grid-physics
  23. Hi There, I use Arcade physics on Phaser3. And I got multiple moveable bodies which stick on top of each other. For two bodies this works, the third does sink a bit into the second and the forth makes the whole stack collapse and fall through the bodies. (example image attached) (edit) Note: Bodies are not falling through static sprites, the described behavior does only apply to dynamic bodies. I would prefer a "not checking" for weight, - setting velocity Y to 0 on collision does inflict many more problems. So this won't solve the issue. I set the OverlapBias on the Arcade physics to 20 (code below) to prevent bodies with high gravity falling through static sprites. The Y gravity is set to 2000, decreasing this amount does not solve the issue and the gravity amount is needed. arcade: { gravity: {x: 0, y: 2000}, debug: true, overlapBias: 20 } What I came around was thinking to set the weight or mass so that the sprites don't "sink" into each others body. Even tho if a body is falling on onto two bodies which are on top of each other, they complete break and fall through. Does anyone have an idea how to fix this?
  24. I know there are some discussions about this topic. But they are outdated & too old. Now it's 2018 , and some physics engines have been updated , and there are some new engines. So , let's talk it again. Which 2D Physics JS Engine is with better performance in 2018 ? matter-js p2.js box2d.js with liquid box2d.ts planck.js or someone else ?
  25. NotKawaiiGirl

    Asteroids Game Like Physics

    Hello! I'm working in a game that use physics like asteroids, the arcades game, but i'm having trouble making "the ship" to move. I'm using whatever sprites I found for testing, so right now the ship is the guy from the first official tutorial in the page of Phaser 3. TL;DR How do I use velocityFromRotation() work for my sprite. I've read the documentation but I just don't get it. Thank you, btw. I put here the code. For now, "the ship" is called "dude". game.js