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

Found 578 results

  1. P2 physics child bug?

    I've played around with P2 physics and created a sprite that has a child attached that can (is supposed to) move freely around the parent. The child should still contribute to collisions with other objects so I gave it a P2 body as well, but it was behaving very odd. A closer look at the debug data revealed that the collision shape and the sprite image are not at the same position o_O in fact the collision shape is located at an absolute position in the world that relates to the relative coordinates between parent and child and does not move at all. Here is an example that you can try with the sandbox editor: game.physics.startSystem(Phaser.Physics.P2JS); var parent = game.add.sprite(200, 200, 'phaser'); game.physics.p2.enable(parent, true); parent.anchor.set(0.5); var child = game.make.sprite(100, 100, 'phaser'); game.physics.p2.enable(child, true); child.body.static = true; child.anchor.set(0.5); child.angle = 0; parent.addChild(child); If you look at the attached image you can see the offset. When dragging the parent around with the mouse the collision shape will stay at a fixed position, but it CAN collide with the parent. This issue might be related to an older discussion: Any ideas how we can fix this (that don't involve creating the child as a "free" sprite and let it follow the parent via the update() function)?
  2. Hi All, Disclaimer: I'm very new to Babylon. I was playing around with this cloth tutorial, and I wanted to make the cloth land on some sort of ground object. So far, I haven't been able to find one that works. You can see in this playground how the cloth reacts to a box impostor, side-by-side with a sphere behaving normally. I have the restitution of everything set to 0. The sphere stops nicely but the cloth shoots off into the distance. I've also tried this with a ground impostor (sphere works fine, cloth doesn't interact with the ground), and a plane impostor (cloth collides correctly, but sphere shoots up into the stratosphere). I have also tried adjusting the initial linear velocity of the cloth particles. More velocity = flies away faster, less velocity = falls right through the ground. My ultimate goal involves the cloth having an initial z velocity, so I'd like to be able to make that work. Can someone help me figure out what I'm missing here? Does it have something to do with the distance joints connecting the particles in the cloth? Should I try using sphere impostors instead of particles? Thanks! (side note: is there a better way to translate the cloth's position than the translatePositions function I made? The built-in ground.rotation.axis method rotates the cloth, but not the actual particles themselves)
  3. Hi, I'm syed and i'm new for phaser. how to add restitution for one object not for whole world Note: using P2JS physics engine
  4. Hello again people! Well, I have a little problem with collisions in babylon with cannon js. For example: I move my player with translate, it's just a box with box impostor, and when I go and crash with another box the player is throw in the other sense, here it's all ok but the force with the player is throw it's very strong. I tried with resitution = 0 or friction = 1 but happens the same strong counter force. So, can anyone help me?
  5. I am getting close to starting a social media promotion to "Release" my new game portal GuiGhost Games. My target is to go after the "Family Friendly" niche, and therefore sticks to games in that theme. All the games on my portal share the same bonus currency "StarCash" that can be earned and spent across the games. I have the Facebook integration currently turned off as the apps are still listed in Dev mode, so those items will not work, but thought I might get some outside opinions on the game play from this community first. Full Disclosure: These games are the product of me following tutorials that I extended, using open source examples that I skinned/tweaked to fit my style. The last year has been spent learning the ins and outs, following tutorials, as well as exploring the many frameworks available. All my games are targeted to be mobile friendly, and attempt to resize and look good on all devices. Some are just skins of open source code, and others started with a tutorial of the basic mechanics and grew into a full game play experience, such as GuiGhost Farms and Gui Bubble Story Here are a couple of screenshots from the games I spent the most time on. Shout out to http://rembound.com/articles, and http://www.emanueleferonato.com for the great tutorials on getting started in HTML5 game development, and to all the great artists on https://opengameart.org/ for the open source assets used in these games. Some of these games are still a little rough around the edges, but I would appreciate any feedback before I start pushing this out on social channels.
  6. I have used this phaser example as a starting point to build a game where shapes are dynamically dropped from the top of the screen and collide with each other: https://phaser.io/examples/v2/p2-physics/pick-up-object What I would like is for the shapes to stop bouncing and vibrating when they collide - but I'm not sure which settings to adjust to achieve this effect (and I've not had much luck with trial and error so far!). I have set gravity like this: game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.gravity.y = 6000; Here is my shapes/sprites json file: { "shapeOne": [ { "density": 2, "friction": 100, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 }, "shape": [ 84, 76 , 0, 160 , 0, 0 , 84, 0 ] } , { "density": 2, "friction": 100, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 }, "shape": [ 84, 76 , 314, 76 , 314, 160 , 0, 160 ] } ], "shapeTwo": [ { "density": 2, "friction": 100, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 }, "shape": [ 0, 0 , 315, 0 , 315, 83 , 0, 83 ] } ], "shapeThree": [ { "density": 2, "friction": 100, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 }, "shape": [ 0, 0 , 237, 0 , 237, 235 , 0, 235 ] } ] } Does anyone know the correct settings to adjust? Do I need to turn density up really high and friction low? And should gravity be high? Here is a screenshot of the shapes that are being dropped into the container:
  7. How to join two mesh

    Hi Everyone, How to attach the two meshes using script. for example: Two meshes i) skateboard ii) player(animated with 3ds max) i will use this to attach sword.attachToBone(skeleton.bones[34], character); Note: i want to attach two meshes i) the skateboard don't move while playing the players animation Advance Thanks...
  8. custom world limits

    Hello guys, When I use p2js by default the borders are the limits of any body inside. I can use planes to reduce this area but it's still a rectangle. My question is the following: How to make an area with curves? Can physicseditor help in a way? Thanks
  9. Hello everyone, Do you know if it is possible to add a custom collision handler for world bound collisions with the arcade physics system? I know that the onWorldBounds signal exists, but from what I've tried it seems to be fired at the beginning of the collision and it does not prevent the velocity changes from being made further down the road. Am I missing something? For clarification what I am trying to achieve is to add random direction displacement to the velocity of a ball each time it collides with the world bounds. Thank you for time.
  10. 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.
  11. Hello there, For the record: I am posting this in BabylonJS since this is the best HTML5 3D game engine for the web and I'm questioning some of its physics engines and their use on the server. I was wondering what the state is regarding (JavaScript) 3D physics engines and the possibility of running the physics on the server (to make the server authoritative). The current state of physics engines seems to lack either performance or functionality. I have tried running CannonJS using NodeJS, and while it was OK for 4-5 clients, it became quite poor afterwards (even though I used simple and few geometry). Oimo.js doesn't have any collision callbacks as far as I've read, and Energy.js's release seems to be quite far away. Another question: it seems that the popular webgames you see on the web are being ''hijacked''. By that I mean that the client code is stolen and are being run on a different server where they make profit. This for instance happened with Agar.io. To counter this, you should preferably run a few things on the client and the majority of the other stuff on the server. However, if a game has physics, I imagine this wouldn't work out so well since it may stutter or feel unresponsive. Does anyone have knowledge of this or can share his/her experience?
  12. Move sprite according to angle

    Hi, I've been trying to figure out how to move a sprite in the direction it is facing. I was originally going to use the p2js "thrust" function, but it caused a small jitter with the camera. I then tried to use the Arcade "velocityFromAngle", but it was not accurate enough. Here is the code I have playerBoat.prototype.update = function () { if(wasd.up.isDown ) this.speed += 2; else this.speed -=2; if(this.speed > 0){ //MATH } if(wasd.left.isDown && this.speed > 0){ this.angle -= 1; } else if(wasd.right.isDown && this.speed > 0){ this.angle += 1; } As someone who was never too strong in math, I am a little bit confused as to how to relate the angle and speed to do what I'm trying to do. I'm assuming it's something with vectors, but I could use some direction. Thanks in advance!
  13. Hi Everyone, How to visually check the sphere imposter shape and size of player in babylon???
  14. how to avoid the bouncing of sphere collider object i want to force stop of bouncing for player because i'm using cannon physics engine when the player jump over the box then the player will bouncing to very large distance in sky
  15. Hi, I am making a snake vs block clone.So obviously the snake and block should collide.When blocks falls on snake collision is working(i mean separation is working).But when i drag snake to a block ,there is no separation when collision happens(only overlapping).Please help me.
  16. 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.
  17. Physics of a Fish.

    QUESTION: How to make a fish tail move? So this is a (brief) STUDY in FISH PHYSICS Hoping this helps others with fish. Here goes...
  18. I just upgraded to Phaser 2.9.3, since then I get a strange behavior. 1. I press Left / Right to change the Sprite's velocity (x). // See update method 2. Sprite has enabled Physics, World.gravity is 2000 // See in create method 3. But the Sprite instead of moving left (negative velocity.x) moves upwards // See attached gif What I figured out till yet: - velocity.y turn to NaN by colliding with a collisionGroup . - velocity.y stays NaN, even if the character moves into the air. (whyever it moves into air..) There is nothing else going on. I tested this as a test-case, not inside my game, to be sure I'm not messing something up. create method: super(state.game, x, y, 'minions'); this.level = state; this.anchor.setTo(0.5); this.game.physics.arcade.enable(this); this.game.add.existing(this); this.body.bounce.set(0.5); this.body.setSize(45, 110, 80, 45) update method: if(this.controls.on("left")) { this.body.velocity.x = -500; this.animations.play('walk'); } else if(this.controls.on("right")) { this.body.velocity.x = 500; this.animations.play('walk'); } Anyone have a clue why this happens? Thanks in advance.
  19. I've been prototyping a local co-op game that involves multiple players moving around on the same screen. Where my trouble has come, is with inputs and handling multiple key presses and movement. I've tried using the action manager to apply forces, impulses, or setting linear velocity on key down, but all of them seem to feel very buggy, especially when trying to press multiple keys. A sample of my code looks like the following: scene.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnKeyDownTrigger, function (evt) { console.log(evt.sourceEvent.key); var velocity = player.physicsImpostor.getLinearVelocity(); if (evt.sourceEvent.key == "w" || evt.sourceEvent.key == "W") { //player.applyImpulse(new BABYLON.Vector3(0, 0, 10), player.position); //player.physicsImpostor.applyForce(new BABYLON.Vector3(0, 0, 100), player.position); player.physicsImpostor.setLinearVelocity(new BABYLON.Vector3(velocity.x, velocity.y, 20)); } if (evt.sourceEvent.key == 'a' || evt.sourceEvent.key == 'A') { //player.applyImpulse(new BABYLON.Vector3(-10, 0, 0), player.position); //player.physicsImpostor.applyForce(new BABYLON.Vector3(-100,0,0), player.position); player.physicsImpostor.setLinearVelocity(new BABYLON.Vector3(-20, velocity.y, velocity.z)); } if (evt.sourceEvent.key == 's' || evt.sourceEvent.key == 'S') { //player.applyImpulse(new BABYLON.Vector3(0, 0, -10), player.position); //player.physicsImpostor.applyForce(new BABYLON.Vector3(0, 0, -100), player.position); player.physicsImpostor.setLinearVelocity(new BABYLON.Vector3(velocity.x, velocity.y, -20)); } if (evt.sourceEvent.key == 'd' || evt.sourceEvent.key == 'D') { //player.applyImpulse(new BABYLON.Vector3(10, 0, 0), player.position); //player.physicsImpostor.applyForce(new BABYLON.Vector3(100, 0, 0), player.position); player.physicsImpostor.setLinearVelocity(new BABYLON.Vector3(20, velocity.y, velocity.z)); } })); scene.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnKeyUpTrigger, function (evt) { console.log(evt.sourceEvent.key + " up"); var velocity = player.physicsImpostor.getLinearVelocity(); if (evt.sourceEvent.key == "w" || evt.sourceEvent.key == "W" || evt.sourceEvent.key == 's' || evt.sourceEvent.key == 'S') { player.physicsImpostor.setLinearVelocity(new BABYLON.Vector3(velocity.x, velocity.y, 0)); } else if (evt.sourceEvent.key == 'a' || evt.sourceEvent.key == 'A' || evt.sourceEvent.key == 'd' || evt.sourceEvent.key == 'D') { player.physicsImpostor.setLinearVelocity(new BABYLON.Vector3(0, velocity.y, velocity.z)); } })); My question is, what is the best practice to handle movement of a simple object (I'm currently just using a cube), and have it work with multiple key presses? Keep in mind this will be repeated for multiple players, so I'd like to to be as modular as possible
  20. Hi, Can I somehow (with physics plugin Oimo.js) set different gravity for different meshes? For example I want to simulate environment in water and I want to have there buoyancy. https://www.babylonjs-playground.com/#2B84TV#7 Thanks a lot for your advice.
  21. Collisions with sprites

    I am making a game where I need to know if a sphere has collided with an enemy. The problem I have is that the enemies are sprites. Is there a way to check collisions with sprites?
  22. I have a mian body that moves freely on the board. To that body I want to attach a recrangle at a certain offset that would visibly dangle and rotate upon forces affecting the main body. How could I achieve that? I tried a set of springs, but I can't get the desired effect.
  23. Hi, i want capsule imposter for my caracter but how can i done that. i'm using cannon.js plugin any other physics engine can support it
  24. So a gotcha of the moveWithCollisions method is that it uses an ellipsoid mesh to calculate collisions of your mesh instead of the original mesh dimensions. I see a clear way to remove your original mesh but how do we remove the ellipsoid mesh from the scene? I'm worried that keeping these ellipsoids even when my original mesh has been disposed of will hurt performance. Thank you so much.
  25. I saw this on Facebook, from a mate of mine: https://fitting3d.com Pixel perfect cloth physics and collision in realtime. Also works on mobile devices. Can Babylon.js do this? Edit: Just realised, maybe the physics was baked into vertex animation instead, 'cos it doesn't look like you can interact with that animation