Attaching colliding object instances with hinges

For questions about using Classic.

Post » Sun Aug 14, 2011 11:33 am

If I have a bunch of instances of an object, with the physics behavior, (such as a bunch of marbles), is there any way that I can form a hinge between two instances that are colliding? This would, in theory, make these instances stick together. And, as more and more collided with each other, they'd start sticking together in chains or bunches.

The problem I have is that,
1: I'm not sure how to differentiate between objects in a collision, such that I can ask only one of them to form a hinge to the other, and
2: since a collision is not a triggered event, but rather the collision condition is tested for on each tick, on a single tick I may have several (e.g. 20) instances colliding.

Is there any simple way to get the kind of behavior I'm describing, or would it really require a triggered event style collision detection?
fisholith2011-08-14 11:37:12
B
21
S
13
G
8
Posts: 306
Reputation: 5,458

Post » Sun Aug 14, 2011 1:50 pm

To create the hinge between ball and ball2, you could use:

+ ball: On collision between ball and ball2
-> ball: Create hinge to ball2 (image point 0) with stiffness 90
-> ball: Disable physics collisions with ball2
(You might not need the last line?)

Heres an example
Cap

These events are not needed, but i added them help with the visual.

+ MouseKeyboard: On key Right arrow pressed
+ ball: overlaps ball2 : offset (1,1)
-> ball: Add force (ball[Physics].VelocityX+240, ball[Physics].VelocityY-240)

+ MouseKeyboard: On key Left arrow pressed
+ ball: overlaps ball2 : offset (1,1)
-> ball: Add force (ball[Physics].VelocityX-240, ball[Physics].VelocityY-240)

Hope this helps
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Mon Aug 15, 2011 7:27 am

I appreciate the reply, and the example.

I may ultimately have to resort to using multiple objects, but what I'm looking for at the moment is a way to form links between multiple instances of a single object. That is, rather than having 5 instances of "ball" and 5 instances of "ball2", I'm looking to have 10 instances just of "ball", where any of those instances can stick to each other.

I'm thinking I may need to employ some Python scripting to store selected instances in variables and or distinguish between individual instances in the Selected Object List. Awesome as Python is, in this case I'd prefer to avoid it if possible.
B
21
S
13
G
8
Posts: 306
Reputation: 5,458

Post » Mon Aug 15, 2011 8:28 am

adding ball to a family, for example, blue, could help you. adding the object allows it to be differentiated from itself in conditions, so lets say, blue collides with ball, would basically mean, ball collides with ball, but now you can differentiate between the two in expressions and actions. its as simple as that. now getting the hinging to work properly is a bit more complicated, but its the same idea. families allow you to get more selectable objects for events involving the same objects, no python needed :).QuaziGNRLnose2011-08-15 08:29:36
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Mon Aug 15, 2011 2:35 pm

Thanks guys. I worked out a system that handles a simplified case of what I'm going for. It will link instances of a single object together in chains or bunches (trees).

Download example cap here.

I'm still interested in getting it to work for an arbitrary number of collisions on a single tick.

(...also, I just got a dropbox account.)fisholith2011-08-15 14:37:33
B
21
S
13
G
8
Posts: 306
Reputation: 5,458


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests