Obi Official Forum
Logic like cut the rope ? - 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: Logic like cut the rope ? (/thread-1408.html)



Logic like cut the rope ? - superdev - 05-10-2019

Hi there,

I went through the documentation and forums while trying to find implementation or any example of creating logic like cut the rope game. I found an example 


Code:
if (Input.GetKeyDown(KeyCode.A))
        {
            Obi.ObiRope rope = GetComponent<Obi.ObiRope>();
            rope.DistanceConstraints.RemoveFromSolver(null);
            rope.BendingConstraints.RemoveFromSolver(null);
            rope.Tear(10);
            rope.BendingConstraints.AddToSolver(this);
            rope.DistanceConstraints.AddToSolver(this);
            rope.BendingConstraints.SetActiveConstraints();
            rope.Solver.UpdateActiveParticles();
        }

But how does this work in making a cut based on swipe made on screen by the player ?


RE: Logic like cut the rope ? - josemendez - 05-10-2019

(05-10-2019, 01:14 PM)superdev Wrote: Hi there,

I went through the documentation and forums while trying to find implementation or any example of creating logic like cut the rope game. I found an example 


Code:
if (Input.GetKeyDown(KeyCode.A))
        {
            Obi.ObiRope rope = GetComponent<Obi.ObiRope>();
            rope.DistanceConstraints.RemoveFromSolver(null);
            rope.BendingConstraints.RemoveFromSolver(null);
            rope.Tear(10);
            rope.BendingConstraints.AddToSolver(this);
            rope.DistanceConstraints.AddToSolver(this);
            rope.BendingConstraints.SetActiveConstraints();
            rope.Solver.UpdateActiveParticles();
        }

But how does this work in making a cut based on swipe made on screen by the player ?

Obi provides a method to cut the rope at a given constraint index, but it's completely up to you to determine which constraint to cut based on your game logic and/or user input.

For a cut-the-rope like game, you need to determine which constraint in the rope intersects the swipe. First thing that comes to mind is iterating over all distance constraints in the rope, an perform a segment/segment intersection test between the swipe and each constraint.

kind regards,


RE: Logic like cut the rope ? - superdev - 05-10-2019

(05-10-2019, 02:52 PM)josemendez Wrote: Obi provides a method to cut the rope at a given constraint index, but it's completely up to you to determine which constraint to cut based on your game logic and/or user input.

For a cut-the-rope like game, you need to determine which constraint in the rope intersects the swipe. First thing that comes to mind is iterating over all distance constraints in the rope, an perform a segment/segment intersection test between the swipe and each constraint.

kind regards,

Thanks for the advice, that seems like its doable, just trying to figure out if its possible and easy to achieve what I want to do or not.