Swinging rope collision question

0 favourites
  • 6 posts
From the Asset Store
In this game, players manipulate threads to match the given patterns, solving intricate puzzles along the way.
  • I'm using a simple method to detect when a swinging rope should wrap around a solid, shown in the topmost image below:

    [attachment=0:1qwhxo44][/attachment:1qwhxo44]

    note - you'll have to scroll down to see the 2nd example

    After the rope collides, a corner tester sprite is placed at each corner of each overlapping solid, & its angle is set away from the pivot. Then it's just a case of picking the corner whose angle most opposes the swing direction, eg. if the rope swings anticlockwise you pick the sprite angled most clockwise to the rope.

    This works for a fixed pivot, but if you have a pair of freely moving physics objects linked together then the above rule no longer applies. In the lower picture imagine the dotted grey lines as the rope's position last frame. They show situations where the rope could intersect while rotating clockwise or anticlockwise, but the same corner as in the top picture would be the wrap point.

    I've been trying to think of some collision rules as elegant as the first situation but can't come up with anything. Any ideas?

  • To be honest I don't see the point of the mechanic.

    I know it doesn't really matter, but logically the end of the pendulum should smack into the solid on the bottom.

  • Here's an example of what I'm using it for (excuse the bugs):

    https://dl.dropboxusercontent.com/u/523 ... index.html

    At the moment you can only hook the green boxes while stationary, but I'd like to be able to have 2 moving objects hooked together.

  • I'm not entirely sure if I'm understanding your problem correctly, but I think- once the mobile-pivot line collides with a block, you want to treat the midpoint of the line as you did the fixed pivot point in the fixed-pivot-example.

    After that, you have two separate lines to work with. Each anchored at the same point on the block. I think.

  • That could be it, I can't see it though - I found another solution that seems to work so my brain has given up on me I appreciate the idea though.

    What I'm doing is storing the rope's start & end positions for the last frame, then when it overlaps a collision box I lerp a ray backwards from the rope to its previous position. Once the ray isn't overlapping the box & is overlapping a corner test sprite, you pick that corner (or if there's more than one, pick the closest to the rope's start).

    With some optimized lerping, it never takes more than 5 loop steps to find the corner, even over large distances.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • mattb might learn from this

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)