Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Logic like cut the rope ?
#1
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 ?
Reply
#2
(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,
Reply
#3
(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.
Reply