• Content count

  • Joined

  • Last visited

  1. How to dispose ellipsoid in moveWithCollisions

    Sorry for the long delay in my response, I was trying to make a PG (no pain no gain ) but couldn't recreate the same situation. I was not using the Wingnut utility function btw so it's all good there! As usual, my own stupidity overcomes me again! If you don't want to waste time don't read below. It seems that what was left behind after my mesh.dispose was not an "ellipsoid mesh" but rather an InstancedMesh object. I originally created my mesh like so monsterInstance.hitbox = monsterType.hitbox.createInstance(); I tried to dispose of the mesh as so... monsterInstance.hitbox.dispose(); It was leaving behind a InstanceMesh object which was still being affected by my other meshes colliding with it. After trying to recreate the error in PG, I eventually found out I was attaching the onCollide handler twice. I was calling the dispose method on my second onCollide handler. I never knew about these Wingnut functions and the utility one to see the ellipsoid will definitely help me! Thanks for your answer
  2. How to dispose ellipsoid in moveWithCollisions

    Hello sorry just saw this now. I will check it out thank you!
  3. 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.
  4. I spent around 4 hours scratching my head and still can't figure this out! If you throw an object in front of you and then move left or right, how can you tell which side you are on? I'm using BabylonJS so it would be super helpful if you could limit the methods used to that library. Otherwise, a clear mathematical question would suffice. Thank you so much!
  5. Sorry I found out that it was my fault in the number of draw calls to the canvas that I used for the map editor. I'm still worried about the performance of using this method of creating custom meshes to populate my map. Is this a good way to do it or am I missing something with the normal Babylon plane object? I did'nt want to use the plane because I didn't want to bother trying to position my planes using the position property.
  6. Hello, noob back Just wanted to ask what may be the best way to approach creating something like a maze from 2D positional data. (Image below to show what im trying to accomplish) I had created something by creating custom meshes which mapped to 2D data but even creating 7 or so planes makes the performance extremely slow. I'm guessing this has something to do with computing normals or creating new vertex data... Not sure. So far each of the custom planes you see below are cloned from a base custom mesh object and then a new vertexData is created for each one based on the XY coordinates of the map and applied on the mesh. Because of the huge performance hit, I'm thinking that this isn't the best way. Can anyone provide any expertise on this please? Thank you. function linedef(startVertex, endVertex, material) { this.startVertex = startVertex; this.endVertex = endVertex; let customMesh = bustomMesh.clone(); const {x, y, z} = startVertex; var positions = [ x, 5, z, x, 0, z, endVertex.x, 0, endVertex.z, x, 5, z, endVertex.x, 0, endVertex.z, endVertex.x, 5, endVertex.z ]; var indices = [0, 1, 2, 3, 4, 5] var vertexData = new BABYLON.VertexData(); vertexData.positions = positions; vertexData.indices = indices; vertexData.applyToMesh(customMesh); var normals = []; //Calculations of normals added BABYLON.VertexData.ComputeNormals(positions, indices, normals); var vertexData = new BABYLON.VertexData(); vertexData.positions = positions; vertexData.indices = indices; //normals = => {return -(n)}) vertexData.normals = normals; //Assignment of normal to vertexData added var uvs = [0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1]; vertexData.uvs = uvs; vertexData.applyToMesh(customMesh); //var redMat = new BABYLON.StandardMaterial("redMat", scene); //redMat.diffuseTexture = new BABYLON.Texture("textures/e1m1wall.png", scene); //redMat.bumpTexture = new BABYLON.Texture("", scene); //customMesh.material = redMat; //customMesh.material.backFaceCulling = true; //showNormals(customMesh, 5, null, scene); customMesh.checkCollisions = true; return customMesh; }
  7. I'm able to get RayHelper working to an extent in the sense that I can only see the ray at certain angles to my mesh that the ray is attached to. Is this a known issue? Thanks all!
  8. Thanks for your suggestions guys. I like the computeWorldMatrix idea since it works more along my game flow. I ended up computing the world matrix for my ground object so that it is lower than the world origin so that nothing will intersect it. If I wanted to add walls and such however, those will still intersect my enemies before they're rendered into the world. Is there a solution to this problem that I'm not aware of or how can I use the camera method with my game render loop logic? Thank you everyone. engine.runRenderLoop(function(){ MapManager.update(); MonsterManager.update(); WeaponsManager.update(); ProjectileManager.update(); cambox.position = camera.position; cambox.rotation = camera.rotation; scene.render(); });
  9. Hello again, I'm trying to figure out how to check for collisions using intersectsMesh method. The problem is that when I start my scene, the intersectsMesh callback is called since I believe the meshes start at the origin point of the world on the first render before they are moved. The PG above demonstrates the problem. If you open up the browser's developer console, you would see "SHOULDNT HAPPEN" when the mesh intersections occurred. Any tips on how to prevent this problem? Thank you!
  10. How to visualize cube nodes in the map

    I guess instead of just a reference point, I meant I need actual game objects that can react to other objects in the scene.
  11. How to visualize cube nodes in the map

    Hello, yes I did. From what I understand the grid material is just a material that covers a mesh right? I still would need a reference to each mesh in order to check collisions on whether or not another mesh had intersected it. I also need to have references to each mesh's position in order to move my units in a certain direction. To show you what i mean, I've updated my application on Now there will be a grid which is just many 1x1 wireframe meshes put together. You can see that as the monster's hitbox collides, the mesh turns red. This game uses the UniversalCamera controls (WASD). Click the left mouse button to fall down to move around. Sorry if I wasn't too clear and thanks for helping! Let me know if you prefer a PG example.
  12. Hello everyone, I'm working on a doom clone which you can try out here I want to create a 3D level grid so that I can visualize my A* path finding algorithm and also use my in game editor to snap cubes to certain points on the map. I tried to make a visualization using a mesh but with many meshes, performance obviously becomes too slow. How can I create a 3D reference grid in my scene yet avoid the performance hit? Thank you so much for your help. I have an image to show how the grid should behave and look like.