![]() |
Help Hot to get Mu out of raycast info - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Help Hot to get Mu out of raycast info (/thread-3201.html) |
Hot to get Mu out of raycast info - Hlibs - 25-11-2021 Hi I've been using raycasting to find specific point on obi rope where the player is watching and can get it's index and position Can I get normalized position mu out of it somehow? RE: Hot to get Mu out of raycast info - josemendez - 25-11-2021 (25-11-2021, 05:32 AM)Hlibs Wrote: Hi Hi there! Do you mean normalized coordinate along the raycast, or along the rope? Also, are you using surface collisions? Along the raycast, mu = result.distance / maxDistance; Along the rope, assuming you use surface collisions the raycast query returns the index of the simplex hit. You have to traverse a couple data structures to get the mu along the rope: - Get the particle indices of the simplex: Code: int simplexStart = solver.simplexCounts.GetSimplexStartAndSize(result.simplexIndex, out int simplexSize); - Look for the rope element that references these particles, and once you find it just divide its index by the amount of elements: Code: for (int i = 0; i < rope.elements.Count; ++i) You could get a finer result by considering the hit position along the current element's length, and adding that to the resulting mu value. kind regards, RE: Hot to get Mu out of raycast info - Hlibs - 25-11-2021 (25-11-2021, 08:39 AM)josemendez Wrote: Hi there!Along the rope, yes Thank you, it's working great now! RE: Hot to get Mu out of raycast info - josemendez - 25-11-2021 (25-11-2021, 10:19 AM)Hlibs Wrote: Along the rope, yes You're welcome! hit me up if you need help ![]() |