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


Messages In This Thread
Logic like cut the rope ? - by superdev - 05-10-2019, 01:14 PM
RE: Logic like cut the rope ? - by josemendez - 05-10-2019, 02:52 PM
RE: Logic like cut the rope ? - by superdev - 05-10-2019, 05:35 PM