Attaching colliding object instances with hinges

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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?

  • 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


    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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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 :).

  • 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.)

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