Search the Community
Showing results for tags 'capsule'.
-
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.
-
I don't seem to see a CreateCapsule in MeshBuilder... I see the CreateCylinder but it does not have "Top" and "Bottom" part of a capsule. How can i create a capsule... Note i already "STEAL" pieces of code from framework to make box and sphere collider meshes... But don't know how to create an actual sphere... Anybody know how... This is what my existing "STOLEN" code looks like for box and sphere... Pretty simple... was hoping capsule would be just as simple: private static applyBoxCollider(box:BABYLON.Mesh, options: { size?: number, width?: number, height?: number, depth?: number, faceUV?: Vector4[], faceColors?: Color4[], sideOrientation?: number, updatable?: boolean }, scene: Scene): void { options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene); box.sideOrientation = options.sideOrientation; var vertexData = VertexData.CreateBox(options); vertexData.applyToMesh(box, options.updatable); } private static applySphereCollider(sphere:BABYLON.Mesh, options: { segments?: number, diameter?: number, diameterX?: number, diameterY?: number, diameterZ?: number, arc?: number, slice?: number, sideOrientation?: number, updatable?: boolean }, scene: any): void { options.sideOrientation = this.updateSideOrientation(options.sideOrientation, scene); sphere.sideOrientation = options.sideOrientation; var vertexData = VertexData.CreateSphere(options); vertexData.applyToMesh(sphere, options.updatable); } private static updateSideOrientation(orientation: number, scene: Scene): number { if (orientation == Mesh.DOUBLESIDE) { return Mesh.DOUBLESIDE; } if (orientation === undefined || orientation === null) { return Mesh.FRONTSIDE; } return orientation; } @Sebavan or @Deltakosh You guys know where I'm going with this... It for "Colliders & Triggers" support in the toolkit
-
it seems i cant even get an error message or a debug body.. it stays a rectangle.. trying with sprite.body.addCapsule(length,radius); thx for any tips!
-
hello everybody! since one of rich's answers to the problem was to use a capsule (instead of a circle/rectangle) i tried to do this (although i don't actually understand how this could solve the problem) one problem with capsules is that it make the mentioned problem even worse (my player can now walk up walls for some reason) the main problem with this is that i don't see the physics body.. i always see a rectangle with the exact size of the sprite but altering parameters of the capsule changes the behavior of my player so i am certain it is applied correctly but not displayed. if i do this: (math.radians is a custom function to convert deg to rad) playershape = player.body.addCapsule(100,15,0,0,Math.radians(90))my player (which is 50 pixels in height) hovers about 25 pixels over the ground.. this seems to be correct because i set the distance between the two points to 100 .. it looks like this: