So i’m having a slight issue with instantiating a “link” prefab on a typical node-link style network visualization app i’m creating. Basically, I have the user create different nodes, and they can create links between them. The links are instantiated as a prefab, and the drawing is done as a LineRenderer. (See first attachment)
My issue here is that I additionally have attached a cylinder collider to this object, because that was simplest to follow the path of the drawn/rendered line. However, the issue i’m having is that the line gets fairly large, and it seems the Cylinder Collider is empty. What i mean by that is that my typical Raycast hit detection to determine if a user has clicked on the link is ONLY triggered on the bounds/edges of the collider. (See attachment2 == it only trigggers if they click within the green collider bounds). I want it to detect a collision no matter where on the line (within the collider) the user clicks. Seems like it should be pretty straightforward…
Have you verified inside the editor that the capsule you are creating is in fact covering the entire line? You will prrobably need to show a little more of your setup and code. A capsule normally picks up raycasts fine.
As far as I understand the initial post his problem is that the line don’t has an unique width. The line starts with a small width and ends with a bigger width (or vice versa). Due to this he can’t cover the line using a standard capsule, box, etc. collider.
And since there is no such thing like a “line collider” I guess he’ll have to manually calculate the collision, or use a polygon or mesh collider or something. But all this (imho) depends on the type of the project (3/2D).
Its a 2D project. Not sure why my username changed, but i’m OP. Am i maybe just doing something wrong? This is the first time i’ve used a 2D project, and capsule colliders.
@ThermalFusion - The second attached screenshot highlights the collider. Its clearly there, but only collides on the outside bounds of the capsule.
I missed that in the second shot, sorry.
You say you are making a 2D project yet you are using 3D colliders. You need to show us your implementation of your raycasting and describe what you want to achieve. Since you’re using 3D colliders and you can hit some parts of the collider it seems to me as if maybe you start your ray in a position that might possibly be inside the capsule.
If your project is 2D you should consider using 2D colliders and Physics2D instead, two Circle and a Box collider to make a capsule.