Jump to content

Collisions detect


MarianG
 Share

Recommended Posts

Hi again.

If I want to check if a mesh is in collision with an unknown mesh, not with function IntersectMesh, because, I don't know mesh name, I have to create a specific function here?

<script src="Babylon/Collisions/babylon.collider.js"></script>

Thanks.

Link to comment
Share on other sites

Maybe try to explain the use case a bit better.

intersectsMesh doesn't require you to know the mesh's name, it requires that you know with which mesh you wish to check interactions.

Are you trying to check intersections against a few meshes that you defined previously? Maybe the OnIntersectionEnter/Exit triggers of the ActionManager might come in handy. Check it out here - http://doc.babylonjs.com/page.php?p=22531

Link to comment
Share on other sites

Looks like what I want.

But for example:

mesh.actionManager.registerAction(new BABYLON.SetValueAction({ trigger: BABYLON.ActionManager.OnIntersectionEnterTrigger, parameter: otherMesh },mesh, "scaling", new BABYLON.Vector3(1.2, 1.2, 1.2)));

otherMesh - I get it with scene.getMeshByName(), no?

 

I will study triggers more, and I will try to create a playground.

 

Thanks RaananW

Link to comment
Share on other sites

Hi, I was a bit busy, but finally, I did it with triggers. And now I have another little problme ;))

Here I try to paint it :))

http://prntscr.com/6bap48  

 

I have, start point of sphere, end point of sphere, intersection point between sphere and box, position of box, scale of box, dorection vector from start to end point,... and I don't know how to check if sphere is moveing on left center of box, or in right center of box.

 

And now, I'm trying to transpose in playground.

Link to comment
Share on other sites

Maybe that playgorund helps you to show the problem: http://playground.babylonjs.com/#1NQTNE#11 (it's from another discussion a while ago but might fit your case, too)

If I understand you right, you want your sphere to take the shortest way around that wall? That would be more like a path finding problem than actual collision detection. You could build a grid (or graph) and use a path finding library like this one: https://github.com/qiao/PathFinding.js/ (there is a link in the description to another fork for using it in 3D space).

If you need something more complex you can check out this post by Samuel Girardin: http://www.html5gamedevs.com/topic/12188-crowd-simulation-or-ia-agents-from-c-to-typescript-with-emscripten-to-tsjs-for-babylonjs/?hl=crowd

I think he uses waypoints to navigate around corners, maybe that's something you want to look into.

Link to comment
Share on other sites

  • 2 weeks later...

Hi guys. I make a little progress.

 

Look here:

 

http://www.babylonjs-playground.com/#21YRPA

 

Click on the ground to make path from ball to mouse up.

It creates the path avoiding the obstacles. And it works in 90% of attempts.

 

Problem is the rest 10%. :))

 

I studied more, and I find that if I can determine if rays, cross obstacle from right of his center, i can pass it from right, if it cross obstacle from left of his center, i can pass it from left.

But i don't know how to determine if rays is cross the obstacle by left center, or by right center.

 

Other ideas are welcome.

 

Thanks in advance.

Link to comment
Share on other sites

  • 4 months later...

Hi. Long time ago I created this topic, when I was young :)

Since then I have been busy, but now I come back to it and here are a new  version.

http://www.babylonjs-playground.com/#1SOEHQ#1

More accuracy, return almost the best option against 2 points.

But it take too much time to work, because of recursivity, and I don't know hot to make it without a recursive function.

Any ideas are welcome. Thanks.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...