brucewong21 Posted November 7, 2017 Share Posted November 7, 2017 https://www.babylonjs-playground.com/#4HUQQ#207 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! Quote Link to comment Share on other sites More sharing options...
mr_pinc Posted November 8, 2017 Share Posted November 8, 2017 The Scene object has a few observables you can use https://www.babylonjs-playground.com/#4HUQQ#208 Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 8, 2017 Share Posted November 8, 2017 To prevent the "shouldn't happen", compute the anotherBox's world matrix again, to make sure its position is updated internally as well : https://www.babylonjs-playground.com/#4HUQQ#209 ** Note - this is a relatively "expensive" task, don't overuse computeWorldMatrix . Quote Link to comment Share on other sites More sharing options...
brucewong21 Posted November 8, 2017 Author Share Posted November 8, 2017 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(); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.