Obi Official Forum
Help Snake wrapping - 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 Snake wrapping (/thread-3552.html)



Snake wrapping - littleanchovy - 11-08-2022

Hey,!, i am using obi rope and i wanted to ask that. Currently i am using sneak scene and i want to wrap an object  with my snake and in scripts i want to know if a sneak is currently wrapping an object.I've checked forums and documentations but unfortunately i couldnt find answers.Do you know how can i achieve this ? Also checking if head of my snake is colliding with snake's body can work i think but i couldnt make it work.


https://prnt.sc/MUdpaFSHkwP3


RE: Snake wrapping - josemendez - 12-08-2022

(11-08-2022, 06:24 PM)littleanchovy Wrote: [color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]Hey,!, i am using obi rope and i wanted to ask that. Currently i am using sneak scene and i want to wrap an object  with my snake and in scripts i want to know if a sneak is currently wrapping an object.I've checked forums and documentations but unfortunately i couldnt find answers.

Hi,

Obi exposes ways to read/write all per-particle properties such as position, velocity or radius:
http://obi.virtualmethodstudio.com/manual/6.3/scriptingparticles.html

Also, it has an API to perform spatial queries (recasts, box/sphere overlaps, etc):
http://obi.virtualmethodstudio.com/manual/6.3/scriptingqueries.html

and a way to retrieve particle-collider contacts and particle-particle contacts:
http://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.html

However, it doesn't have any built-in way to know if a rope is "wrapped" around an object, since the concept of "wrapped" can vary a lot depending on the game: does it mean the rope is circling around an object, without touching it? how close to a circle must its shape be? or does it mean the rope is in contact with the object?what percentage of the rope must be in contact with the object for us to consider it wrapped? etc.

In your specific case, seems like it's enough for the rope to form a circle around an object? In that case, you could get the particle positions relative to the object, convert them from cartesian to polar coordinates, and just make sure their angles increase monotonically (the angle for the next particle in the rope is always larger than the angle of the previous one). If they do, that would mean rope particles roughly form a circle around the object.

kind regards,