Rope physics between pegs

0 favourites
From the Asset Store
In this game, players manipulate threads to match the given patterns, solving intricate puzzles along the way.
  • Hi All

    I'm experimenting with making a game where you can place two pegs to create a physics-enabled rope between them.

    I have been going round in circles and wondered if anyone could take a look?

    As far as I can see the while loop is not executing.

    I'm trying to make it loop until I have spawned enough rope pieces between the two pegs, and stop once I'm over the destination peg.

    So the logic I've tried to use it "do whilst the most recently added rope segment is not overlapping the destination peg"

  • I've bought a license and written a version using families to pin each rope section to the last. Still no joy though :(

  • Hi,

    I changed the While to Every 0.5 seconds to see whats happening.

    Looks like its working.

    Will have a better look later if this doesnt help.


    I dont know why you have the fade behavour on the rope but i dont think it likes the physics behavour.

  • I want ropes to fade/destroy once they aren't pinned to a peg anywhere down the entire set of ropes.

    But for now I'd be happy if I could just see a rope bridge appear between two points, with each rope segment affected by gravity (for e.g. for a player to walk across and it would bulge).

  • :) I'm having a headache because of thinking of your problem... Since yesterday I'm trying and trying different combinations but no success until now... Damn, it sounds so easy...

  • Hi.

    See this post:

    You can create the rope, like the laser.

    the example:

  • The problem is newly created objects aren't properly created until the next top-level event (see this). Which means you can't pick those rope parts by UID until after event 2 has finished completely. You might try creating all the rope parts first and then looping through them and joining them together in the next top-level event. For example: physicsBridge.capx (r119)

  • I appreciate the comments so far but still don't understand.

    I've looked at the issue highlighted in that post ramones but as far as I see my code doesn't do that. It uses nested functions, all effectively fired "within" event 4.

    Mouse Click (event 2)

    Sub-event 4 create peg, pin to wall. Call Create Brige

         "Create Bridge"

            "Add Bridge" (loop)

    Do functions not work like this? In my head they'd have the above nesting. In the event sheet they show as top level events.

    I've also looked at your bridge example (thanks btw) and if need be I'll try rewrite mine to work the same (assuming I can with dynamic pegs), though I'm still stumped over why it isn't working through functions.

  • Functions have their own picking though. Picked objects don't stay picked when you call a function. But they don't count as top level events for object creation either.

    So the peg you create in event 3 can't be picked in the "CreateBridge" function in event 8. And the ropes spawned in the "AddRope" function can't be picked in event 8. Any object you create in event 2 or in the two functions called can't be repicked until event 2 finishes.

  • Thanks for help so far. I've stripped the functions out and tried to follow a similar structure to yours. Was almost getting somewhere but now I am scratching my head over event number 4 in this one.

    It isn't getting the Source peg, even though it was created in top level event #1 and I'm looking for it in another top level event #2.

    Have debugged a bit more and Dest Peg gets picked fine.

  • You need a 'System: Pick all Peg' in event 4 before you can pick the source Peg because the Peg created in event 3 will be the only one picked at that point.

    You're still going to have a problem creating Ropes in a loop. Picking 'Ropes instance Ropes.Count - 1' isn't going to pick the last Rope created inside the loop. You should probably store the x,y values in global variables instead.

  • Ah so "pick" is actually like a "filter" in the sense that if you filter more than once you are constantly working with a reduced set of objects.

    And that applies not only to the pick command but to any conditional checks which also select specific instances of objects.

    You've probably noticed I'm quite new to c2 ;)

    I'll have another stab at this and post an update later. Am engrossed in a second game right now.

  • Yeah exactly, at the start of each top-level event all objects are picked/selected and any actions apply to all of them. Then each condition you have filters the list of selected objects. 'System: Pick all' resets the filter.

  • Latest version is up. It seems to sort of be getting there but it goes all screwy.

    Also of interest, when I did this

    "Pick all peg"

    "Pick source peg"

    it worked

    But then followed directly with

    "Pick all peg"

    "Pick dest peg"

    .. dest peg wasn't found, in fact only finds it without "pick all". Can't get my head around that one.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can't pick dest peg because it's just been created. When you create an object then it is picked and stays picked in sub-events. But if you unpick then you can't pick it again. And if you use pick all, that will pick all the pegs except for dest peg because it's not yet pickable. I know - it's confusing. <img src="smileys/smiley36.gif" border="0" align="middle">


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