Arte Posted August 1, 2017 Share Posted August 1, 2017 Hey guys, I need your help again. How to catch collision point (face) using moveWithCollisions? Thank you. Quote Link to comment Share on other sites More sharing options...
TomaszFurca Posted August 1, 2017 Share Posted August 1, 2017 Hi, I think the best option would be use intersect with mesh -> https://doc.babylonjs.com/tutorials/intersect_collisions_-_mesh. Quote Link to comment Share on other sites More sharing options...
Arte Posted August 1, 2017 Author Share Posted August 1, 2017 Can I use intersect from array or i need to loop for each ob..? I don't know how to get info about intersect point (between two objects). After collision mesh bounces back when I,m using moveWithCollision. I want to snap to collide objects. http://www.babylonjs-playground.com/#T9HZNT Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 1, 2017 Share Posted August 1, 2017 Hey @TomaszFurca (good to see you again)... umm... you were also seeking precision "point of intersect" at one time, right? @Arte - I think a "picking ray" can give you a precise point-of-intersect, onCollideObservable, or ActionManager OnIntersectionEnterTrigger. With intersectsMesh... not sure. And yes, looping through a pile of mesh... checking EACH for intersection with something... sucks. Possibly, onCollideObservable and onIntersectionEnterTrigger can avoid that looping. First, let's "roll out" Tommy's barrels, again. https://www.babylonjs-playground.com/#WWCK0#40 WASD keys move LEFT barrel1, and SHIFTED WASD keys move RIGHT barrel2. Watch console. The ONLY intersection system active by default in this scene... is a barrel2 (right one) actionManager OnIntersectionEnterTrigger in lines 134-143. AND... it is NOT WORKING for some reason. You can use 'd' to move barrel1 into barrel2, or use 'A' to move barrel2 into barrel1. It never triggers. This is POSSIBLY due-to the method we use to move the barrels. .moveWithCollisions() might not be compatible with actionManagers. But, it could be a Wingnut mistake, too. Try setting barrel1 and barrel2 .checkCollisions = true; in lines 105 and 118. Remember that we are currently using .moveWithCollisions() to move the mesh. No dragging active, where moveWithCollisions() might not be usable. After setting checkCollisions true on both barrels, moveWithCollisions IS stopping the mesh when it collides , but moveWithCollisions() is seemingly ignored by actionManager OnIntersectionEnterTrigger. Still, likely a Wingnut mistake... I make those quite often. Let's move on... Highlight codeblock lines 134-143 and tap control-/ to disable that block of code. Highlight codeblock lines 124-132 and tap control-/ to enable that block of code. RUN! Now we have collide observers on both barrels. Try some A and D keys, and some shifted A and D keys. When a moving box collides with another, the onCollide on the moving box... DOES trigger. Its 'd' variable IS the mesh it collided-with. Watch console reports coming from lines 125 and 130... both printing d.name to console. Okay, I don't know if ANY of this crap can be used to avoid looping through all intersect-able mesh in a scene, but maybe. The BJS observer/observables system is already a "loop through everything that needs observing" -system, so, it would be wise to use THAT as your "checking loop", I think. Smarter people may comment soon. Geez, let's HOPE SO, anyway. At least we have a cool testing-playground, eh? I suppose we should try a NON-moveWithCollisions() movement method, eh? Learn from that, too. Hope this helps. Quote Link to comment Share on other sites More sharing options...
Arte Posted August 1, 2017 Author Share Posted August 1, 2017 Hey Wing... This forum without you like "lake without any fish" onCollideObservable = best crap (I'm avoiding loop with this crap) Now I need just find witch face is collided, but I can calculate from last position which direction it's moving. Thank you for your help - AGAIN. GameMonetize and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
TomaszFurca Posted August 2, 2017 Share Posted August 2, 2017 Good tips. Already changed looping my colliders array in scene after render function to action manager, because action manager is fired only when object intersect, so i do need to check all colliders in camera frumstrum. Next good point to optimize my game. Also I fixed PG https://www.babylonjs-playground.com/#WWCK0#41. You need to set parameter in action manager. Parameter value is mesh with which you want register function. 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.