Search the Community

Showing results for tags 'cannon'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 25 results

  1. 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: 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.
  2. Hi again. I make model as simple as possible. Just Basic Sphere and box colliders. I export it with ToB Exporter to get ModelFinish_Base.js. I include this in playground. I created complete playground. I include playground in attached .zip file. Because I can not save playground! Download attached file unzip and copy text from BabylonJS_ToB_Physics_Collision_Problem_Playground.js and paste it in playground and run it. I would like to know why .physicsImpostor doesn't work? Can anybody debug this and find a problem? Is there problem with babylonjs plugin, cannon or ToB exporter ???
  3. @RaananW Hi all, I have some simple playground. I would like to try set up purple Bridge and red Hinge, like physics hinge joint. I create this little scene with blender and export it with exporter 5.0.5. Here is a playground (in comment there is also .blender and .babylon file) Can anybody explain me how to set things right. Origion/Position of Hinge (cilinder) is in center of object HInge. Origin/Position of Bridge is in center of the bottom face of Bridge. I would like that Bridge should be vertical above Hinge. And when ball hit Bridge, the Bridge should fall down like real Bridge. I would like that pivot of Bridge should be at point of Bridge's origin/position. (or maybe origion/position of Hinge/red cilinder). Axis is x-axis. I really don't understand things? I spend all day on this example. If I understand right, I should Use HingeJoint. (Or should I use Hinge2Joint) ? mainPivot: ( I think this should be center/position/origin of Hinge connectedPivot: ? I don't understend why and what to set mainAxis: (I think should be x-axis (red Hinge object) connectedAxis: ? I don't understend why and what to set Can anybody explain connectedPivot and connectedAxis ??? greetings ian
  4. 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
  5. Hello, As some of you may know, we have been forced to introduce a breaking change in the way to use the physics engines starting with v2.4. We try as much as possible to avoid breaking but sometimes it can help introducing a much better way to achieve something. This is the case for physics as now, the physics impostor and its associated mesh are better linked. To better understand why, extract from the doc: "The physics impostor synchronizes the physics engine's body and the connected object with each frame. That means that changing the object's position or rotation in Babylon code will also move the impostor. The impostor is also the one updating the object's position after the physics engine is finished calculating the next step". In previous implementation, we had a lot of users questions & feedback that didn't understand why moving the mesh wasn't doing anything once it was transformed into a "physic object". Please read our documentation to better understand how to use physics in Babylon.js: I've then updated my tutorial and the default sample of our main page: - Understanding collisions & physics by building a cool WebGL Babylon.js demo with Oimo.js: - Main sample: Thanks! David
  6. I have recently run into a problem with the physics joints in Babylon. I add a distance joint between two impostors in my scene, but after some time, I would like to remove that joint. Currently on the docs, there is no reference to a removeJoint function, and after looking into some of Babylon's source code, I found the function link: However, the function appears as if it is not complete, and I am unsure of the proper way to access it. Is there a way to properly remove a physics joint?
  7. Hi all After I parent a mesh with impostor to a camera, and assign position to it relative to Camera, X & Z axis locations work correctly, but not Y-axis location. The mesh jumps up and actually the jumping depends on the value of the Y component the Cannon engine is initialized. Checkout
  8. I have recently started on a Babylon project, and I have been wanting to create a capsule physics impostor for my game. I found a test demo for Oimo.js that basically achieves what I want: compound test (capsule). There are two problems: 1. due to some shortcomings in Oimo, I have had to switch to Cannon.js. 2. the demo uses Three.js and I'm sure how to exactly translate that into Babylon. I basically want to be able to combine two sphere impostors with a cylinder impostor. I'm not sure what is the best method for this, there are only a few examples that I have found, and I haven't found anything in the docs. So I created an example to show what I am talking about: capsule sandbox. I have created the capsule mesh, but I just need to figure out how to add a capsule impostor. Thanks.
  9. JBP

    Physics Worker

    Hello, can anyone tell me if the current implementation of the Physics engines (oimo, cannon) support Web Worker or its a single thread implementation ?
  10. Hi, Thought I'd pop this in here as it's my first post but it might require moving to bugs. I'm trying to toggle physics on and off for certain meshes, I've knocked together this simple demo which basically works: On run the 10 planes drop on to the box, bounce around a bit then settle. All good. If you then click the scene it should go in to a physics paused state and the 10 planes reset themselves above the plane. Cannon is throwing an error here and so the 2nd to 10th plane slowly start sinking down. Error stems from line 68. If I use Oimo then the pause state works well however the unpaused physics motion is a bit mad so I'd prefer to stick with Cannon. So really, this leaves me with two questions. Is the way I'm changing the physics impostors the best way enable/disable physics? And, is this a bug in CannonJS? Cheers, Rob
  11. If we have vertical bar and horizontal bar on top of vertical bar. and if we set joint like horizontalBar should rotate around Y (in blender around Z). If I push horizontalBar, two edges of horizontalBar is rotatin around Y but edges of horizontalBar are also swinging up and down (Z). When horizontal bar is rotationg edges are changing Y a little bit. Edges doesn't always have Y=3 like mainAxis have it. Can I lock hinge so that edges of horizontalBar will not swinging up and down and it will always rotate with same Y=3. Or I push too hard horizontalBar? Or is there any other/strange problem? Should edges of horizontal bar always rotate with same Y values (in this case Y=always 3)? var joint = new BABYLON.HingeJoint({ mainPivot: new BABYLON.Vector3(0, 0, 0), connectedPivot: new BABYLON.Vector3(0, 3, 0), mainAxis: new BABYLON.Vector3(0, 1, 0), connectedAxis: new BABYLON.Vector3(0, 1, 0) }); verticalBar.physicsImpostor.addJoint(horizontalBar.physicsImpostor, joint);
  12. How can we use cannon's native API with babylon?. Are/Is there any example(s)? How cen we set up sphere and plane/box? (any simple example?) Must we always set physics Impostor/Collider on mesh which has checkCollisions = true ?
  13. I use babylon.2.4.0-alpha with cannon version 0.6.2 (for physics and SphereImpostor I need cannon because it implements mesh impostor. I have ball and set it this values playBall.setPhysicsState( { impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 1, restitution: 0 } ); Can anybody tell me if there are problems with mass and restitution, because if I change value there is no diffrenece ! If I use oimo physics then there is difference if I change mass and restitution, but I need mesh impostor for maze. So I can use oimo. Can anybody thell me if there is bug in cannon for mass and restituion ? Or in cannon.js is not implemented mass and resitution?
  14. Hello I am trying to develop a FPS using BabylonJS and CannonJS in TypeScript. My first problem was what type of Impostor to use as the player, end up using a Cylinder with a FixedRotation = true. Now I place the camera on top off the Cylinder on every frame, and apply Impulses to the Cylinder based on keyboard input, and camera target. The algorithm that I came up is the flowing (hero = Cylinder): scene.registerBeforeRender(function () { //Your code here //Step camera.position.x = hero.position.x; camera.position.y = hero.position.y + 1.0; camera.position.z = hero.position.z; let camFront = camera.getFrontPosition(1.0); let vecFront = camFront.subtract(camera.position); vecFront.normalize(); let finalVector = new BABYLON.Vector3(0.0, 0.0, 0.0); if (moveForward) { finalVector = finalVector.add(new BABYLON.Vector3(1.0 * vecFront.x, 0.0, 1.0 * vecFront.z)); } if (moveBackward) { finalVector = finalVector.add(new BABYLON.Vector3(-1.0 * vecFront.x, 0.0, -1.0 * vecFront.z)); } if (moveRight) { let q = BABYLON.Quaternion.RotationAxis(BABYLON.Axis.Y, BABYLON.Tools.ToRadians(90)); let m = new BABYLON.Matrix(); q.toRotationMatrix(m); let vecRight = BABYLON.Vector3.TransformCoordinates(vecFront, m); vecRight.normalize(); finalVector = finalVector.add(new BABYLON.Vector3(1.0 * vecRight.x, 0.0, 1.0 * vecRight.z)); } if (moveLeft) { let q = BABYLON.Quaternion.RotationAxis(BABYLON.Axis.Y, BABYLON.Tools.ToRadians(-90)); let m = new BABYLON.Matrix(); q.toRotationMatrix(m); let vecLeft = BABYLON.Vector3.TransformCoordinates(vecFront, m); vecLeft.normalize(); finalVector = finalVector.add(new BABYLON.Vector3(1.0 * vecLeft.x, 0.0, 1.0 * vecLeft.z)); } finalVector = finalVector.normalize(); hero.physicsImpostor.applyImpulse(new BABYLON.Vector3(15.0 * finalVector.x, 0.0, 15.0 * finalVector.z), hero.getAbsolutePosition()); }); Is there a more effective way to do this ? Thanks in advance.
  15. Hello I have submit a question in the Questions & Answers sections: But I my problem is not in decode but in the BABYLON.JS Resume: The control works but the problem is that the camera/hero doesn't go straight forward all the time. Example if at start I point at the Box at the top left if and only press 'W' it goes straight to the Box, but if I for example go straight 'W' for 1-5 seconds and then point at the Box and press 'W' the camera/hero doesn't go straight to the BOX, it goes sides ways. Can anyone please check this out ?
  16. Hello, I'm currently working on physics right now and can't get the camera to be a physic-based-object. How can I handle collisions between player and a scene without using the default camera.ellipsoid or enabling for each mesh the mesh.checkCollissions property? I'd like to have a basic impostor on my camera with player model (Cylinder, capsule or even box). Maybe someone can rewrite this by using a physics plugin 100% It would be so great if this works in the end. Thanks for every answer, Simon
  17. 1.) physics Ok I have some showcase . Just a maze mesh and sphere. I use cannon physics. The ball is not beave as in version 2.4.0-alpha. For me as I tested and check my code is 2.4.0-alpha the most stable. what happend chanded with 2.4.0 and 2.5-alpha. In this two versions when ball initialized and fall down to road it strange deduct far away from road. Strange is because boath have restitution 0. But physics behave like restitution is a some "big" value. ( This below code works perfectly in version 2.4.0-alpha ) playBall.physicsImpostor = new BABYLON.PhysicsImpostor(playBall, BABYLON.PhysicsImpostor.SphereImpostor, { mass: 0.1, friction: 0.01, restitution: 0 }, scene); and road.setPhysicsState( { impostor: BABYLON.PhysicsEngine.MeshImpostor, mass: 0, friction: 0.01, restitution: 0 } ); Can andbody look at this problem? Or have I miss anything? 2.) animation Also animation elivator works fine wiht 2.4.0-alpha but in 2.4.0 and 2.5-alpha I get error in render loop . (our in our showcase is same - I just change version of babylon.js and cannon.js ) error is this: cannon.js:4487 Uncaught TypeError: Cannot read property 'x' of nullQuaternion.copy @ cannon.js:4487CannonJSPlugin._updatePhysicsBodyTransformation @ babylon.max.js:49794CannonJSPlugin.generatePhysicsBody @ babylon.max.js:49532PhysicsEngine.addImpostor @ babylon.max.js:30171PhysicsImpostor._init @ babylon.max.js:29860PhysicsImpostor.forceUpdate @ babylon.max.js:29884set @ babylon.max.js:9863Animation.setValue @ babylon.max.js:28036Animation.animate @ babylon.max.js:28150Animatable._animate @ babylon.max.js:28460Scene._animate @ babylon.max.js:16599Scene.render @ babylon.max.js:17397(anonymous function) @ Game.js:305Engine._renderLoop @ babylon.max.js:6677 is animation chanced or what happend ind cannonn quarteniont copy (there should be some chances rom 2.4.0-alpha to (2.4.0 and 2.5-alpha). greetings
  18. Update - the game is now available on Google Play as a native app: The link Description Naval Battle is an HTML5 arcade game in which your mission is to destroy a fleet of enemy cargo ships before they deliver ammunition and provisions to the enemy troops. You are the commander of the VIC Victory, a fast light tank used by the Mobile Costal Artillery in defending a country against sea attacks. Your tank is armed with a limitless supply of anti-ship shells, but be aware that only one shell can be in view at a time! You have only 70 seconds to sink all enemy ships. They are not armed, but they are protected by the gun fire from a fortified enemy battery on the other side of the bay. And they are moving with different speeds. So you need to aim very carefully! The game ends if you fail to complete the mission within the 70-second time limit or if your tank is destroyed by enemy gun fire. Controls Use the left and right keys to move. Use the up or space key to fire. Screenshots
  19. ndmoeller

    Cannon Duckies

    Hi Everyone! Just wanted to post my first Phaser game, Cannon Duckies: Play Here: Google Play:
  20. Hello guys, at first: Wow, what a helpful community, I have learned a lot by reading here and using your samples on the playground - thanks! Now, here is my problem: I want to show the oscillations of a stacker crane with the cannon-plugin, because I need the spring-constraints to simulate the stiffness of the crane. Because there is no slider-constraint, I am using a workaround with the createCompoundImpostor to "bind" the load handling device to the crane. But I don't really know how to use this function correctly. I've only found one example, which works, yes, but the declaration of the function is another... (vsCode with typescript tells me: Supplied Parameters do not match ...). In addition, the createCompoundImpostor is deprecated, but what is the alternative? I can't get the impostor.parent to work. I made a simple playground example for you: You can click on the green box to move the crane and click on the crane to move down the load handling device. Because there is no slider-constraint, I have to move the geometric objects down and then add all the joints again, because I'm calling impostor.forceupdate(). If it's important: I'm using imported 3D-Models from Blender in my current version, but for physics I'm using the boximpostors with visibility = 0. Actually my question is: How to use the createCompoundImpostor correctly or better what is the alternative? Thank you!
  21. I use babylon.2.4.0-alpha with cannon version 0.6.2 (for physics and SphereImpostor I need cannon because it implements mesh impostor. I have ball and set it this values playBall.setPhysicsState( { impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 1, restitution: 0 } ); Can anybody tell me if there are problems with mass and restitution, because if I change value there is no diffrenece ! If I use oimo physics then there is difference if I change mass and restitution, but I need mesh impostor for maze. So I can use oimo. Can anybody thell me if there is bug in cannon for mass and restituion ? Or in cannon.js is not implemented mass and resitution?
  22. Hey you guys, I recently made a little clone/remake of "Paratrooper" to get into Phaser. The game is far from perfect, and the performance isn't great as I probably use a lot of "bad practice"-code. But I'd be really happy if you could try it out and maybe even answer the questionnaire. It's also meant as a study about game-balance and game-motivation. You can play the game at Greetings and thank you, Max Here are some screenshots:
  23. Hey guys! I'm trying to make some advanced physics in my babylon project. To be more concrete: There is a brick wall and a cannon in front of it. Cannon makes a shot and when the shell collides with wall I want to shatter them. So, for the wall I have two options: Voronoi FractureBreak the wall into bricksAssume I will use second one. According to forums I should break wall mesh into group of bricks with joints and remove some of them if the force is too strong. And this is where the question appears: what is the best option to deal with it? Should I expand oimo/cannon plugin to have more control over joints and ability to add native event listeners for collisions or just use Actions with intersection trigger? For now both plugins hide their world property and just implement plugin interface. Thanks. p.s. I'm new for babylon so it will be great if you could answer more detailed!
  24. Temechon

    Physic test - Oimo.js

    Hey guys ! I really wanted to try to use Oimo.js with Babylon, so I made a quick test here : (Maybe for a new tutorial, who knows ? ) The thing is: it works reaaally well ! In my scene, I create 1000 spheres, and no problem at all. You can compare with cannon.js here : With cannonjs, i can see a lot of sphere are going through the ground, and the fps is not very high. I may work on the plugin creation if you are interested. Cheers !
  25. gledex

    Rush The Top

    Hi everyone, First of all, i want to say thanks to the creator of this wonderful forum, a place where we game developers around the world, have a place to share and learn. -------------------------------------------------------------------------------- Now, i want to present you my latest, but first game creation: Rush The Top PLAY IT The game consists of making use of a cannon to launch a monkey into the space, get coins to buy upgrades and abilities to reach the top in the lowest amount of time possible. Although i have not tested it with iOS and other devices (i don't have them), you can try it out and see if it works for you. PLAY IT Your feedback is ENORMOUSLY appreciated. Thank you, Gastón - One Beast Games