03-11-2020, 03:35 PM
(This post was last modified: 03-11-2020, 03:46 PM by josemendez.)
Hi there!
As per the manual, a rope is essentially a list of points (particles) chained together. An element is just a line segment in between two particles. Particles are identified by their index in a solver.
From this you can conclude that "particle1" and "particle2" are the indices of the two particles at each end of the element.
You can't directly "raycast" against line segments because they have no volume or thickness. You can however cast a ray against particles (which is what the ObiParticlePicker utility component does), or treat segments as swept volumes (cylinders/capsules) and cast against that.
Note that there's no built-in raycast functions against either particles or elements, but it's trivial to write your own: casting against a particle is simply a point-segment distance test (you can use ObiUtils.ProjectPointLine or Vector3.Project for this) and casting against an element is just a segment-segment distance test.
Most of this is just general 3D math knowledge, so it isn't covered by the manual or youtube tutorials. All Obi does is expose a list of particles and their properties (positions, velocities, radius, etc) that you can get/set at any time (see:
http://obi.virtualmethodstudio.com/tutor...icles.html). What you do with this particle data is up to you.
To detect collisions against colliders, you can subscribe to solver.OnCollision:
http://obi.virtualmethodstudio.com/tutor...sions.html
Code:
what are "particle1" and "particle 2" inside of an element and such, the documentation only says they're ints but I'm not sure what they do
As per the manual, a rope is essentially a list of points (particles) chained together. An element is just a line segment in between two particles. Particles are identified by their index in a solver.
From this you can conclude that "particle1" and "particle2" are the indices of the two particles at each end of the element.
Code:
But how can I detect a specific element by raycast hit?
You can't directly "raycast" against line segments because they have no volume or thickness. You can however cast a ray against particles (which is what the ObiParticlePicker utility component does), or treat segments as swept volumes (cylinders/capsules) and cast against that.
Note that there's no built-in raycast functions against either particles or elements, but it's trivial to write your own: casting against a particle is simply a point-segment distance test (you can use ObiUtils.ProjectPointLine or Vector3.Project for this) and casting against an element is just a segment-segment distance test.
Most of this is just general 3D math knowledge, so it isn't covered by the manual or youtube tutorials. All Obi does is expose a list of particles and their properties (positions, velocities, radius, etc) that you can get/set at any time (see:
http://obi.virtualmethodstudio.com/tutor...icles.html). What you do with this particle data is up to you.
Quote:it would serve me well to know how to do the same for collider collisions with the rope as well!
To detect collisions against colliders, you can subscribe to solver.OnCollision:
http://obi.virtualmethodstudio.com/tutor...sions.html