Swinging rope collision question

Get help using Construct 2

Post » Tue Jan 27, 2015 10:14 pm

I'm using a simple method to detect when a swinging rope should wrap around a solid, shown in the topmost image below:

Untitled-1-01.png

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?
You do not have the required permissions to view the files attached to this post.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Tue Jan 27, 2015 11:50 pm

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.
Image ImageImage
B
168
S
50
G
169
Posts: 8,283
Reputation: 108,195

Post » Wed Jan 28, 2015 12:21 am

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.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Wed Jan 28, 2015 4:20 pm

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.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Wed Jan 28, 2015 6:15 pm

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.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

Post » Thu Jan 29, 2015 1:00 pm

mattb might learn from this
You do not have the required permissions to view the files attached to this post.
B
249
S
39
G
15
Posts: 1,952
Reputation: 40,579


Return to How do I....?

Who is online

Users browsing this forum: luckyrawatlucky, nahima and 5 guests