Unity is there a way to find the edge intersect?

Started by
3 comments, last by Scouting Ninja 5 years, 11 months ago

Once again Unity is frustrating me to the point of insanity.

What I am looking for is a way to find a ray intersect with the edges of the mesh, using Unity's already made collision system. I want to point out that I know how to do a line intersect, what I want to know is if Unity supports this already.

RayHitExample.jpg.de419ddb69fb7a6719e796c2b91f34de.jpg

The image above shows how I sweep a ray,intersecting the mesh. The top green image shows what I want and the red shows what Unity is giving me.

I want to know if there is some way, to find the edges in Unity without creating a custom line intersection tool.

Most engines I know don't use rays for this but instead use a plane like this:

RayHitPlane.jpg.4dd0609cf5eb02aac5630ad22f8ba54b.jpg

I checked the Unity "Plane intersection" but it is just a ray cast. It will still need me to find the vertices on the collision mesh to cast the ray from; if I am doing that then making my own line intersection tool is better.

 

I looked online and can find anything on this. Also I don't want to cut the mesh, so I don't need a way to know what side is what.

Does Unity even have collisions that support edge only detection?

Advertisement

Shamelessly bumping my post hoping someone knows a answer. At least I have a update. So I couldn't find the Unity collider function for this, but I realized I already have line formulas in my script.

Mainly I was using the slope intercept formula, y =mx+b.

However I realized that if I used the point slope form, aY-bY = Slope(aX-bX ) ,I could mod it like this -> aY = Slope( aX-bX) then use: Slope( aX-bX) +bY = Slope( aX-bX) +bY where both the aX are unknown variables to find the aX point of the line.

This I made easier to read for the computer, by placing both unknowns on one side, like this: Slope(aX)- Slope(aX) = Slope(bX) +bY - (Slope(bX) +bY).

My result:

LineIntersect.jpg.a9e7142bb4c7bbf7cb6f9fe3ee88d579.jpg

A very neat thing is that this isn't a intersect between vectors but a intersect between lines. There is no constraint to the size of the line, I can use this to find intersections that are beyond the rendered scene easily:

LineIntersectExtend.jpg.dd92fa8f2025b5df5c5704796759a6ba.jpg

 

The problem I have is that this is still adding a collision system over the existing collision system that Unity has. Worst part I will need to create some kind of tool for the editor to add these lines to existing collision boxes.

 

 

You should try Unity3D official forum to ask your question,I'm sure they DO know better than here.

https://forum.unity.com/

Second,Unity3D is much like a cross platform 3D Game Level Editor,you should always write your own code to get special feature.

Third,have you read <Realtime Collision Detection> or <3D Game Engine Design>,they just teach you how to check line segment intersection.You can practice to accomplish this in Unity3D within a few hours as I did last year.Also you can write you own Mesh Collision with the knowledge those book privided.

7 minutes ago, tracegame said:

You should try Unity3D official forum to ask your question,I'm sure they DO know better than here.

I did and the answers they provided was enough to give me nightmares. Things like finding the collision point to find the triangle, the finding the edge by checking the nearest vertices to the collision point, using a ray or a vector intersect to find the intersect point.

It was much more efficient to just make my own system, in the editor.

10 minutes ago, tracegame said:

Second,Unity3D is much like a cross platform 3D Game Level Editor,you should always write your own code to get special feature.

Every time I make a game with Unity it just slams me in the face with a reminder that the tools are only skin deep. I want to make games not tools!

However, it at least allows me some flexible ways to make tools. I used the Unity scriptable object to hold the line colliders.

18 minutes ago, tracegame said:

Third,have you read <Realtime Collision Detection>

I am using Christer Ericson :Real Time Collision Detection. Is it this one you mean? I actually made a system like this for the irrlicht engine before. So it isn't like I am covering new ground.

I thought Unity would already have it, because it is covered in almost any collision book and lots of other engines I use have something for this. I didn't want to re-make a already perfect working collision system.

 

Unfortunately it is unclear if Unity can do this. None of the frequent Unity users know and the manual doesn't say.

Thanks for the help.

This topic is closed to new replies.

Advertisement