Difficult collision problem

0 favourites
  • 8 posts
  • Hello everyone, I prevent a perplexing problem.

    Let's say I have two click-and drag nodes, with a bar that always extends between them. A simple matter to program.

    <img src="http://i.imgur.com/cg0Pv.png" border="0" />

    The nodes can be dragged around the layout at will and the bar will always extend between them (simple programming).

    Now, in the context of this arrangement, there will be some walls/obstacles in the layout.

    <img src="http://i.imgur.com/X08tW.png" border="0" />

    How can I program the arrangement so that the user can never position the system so that any object (nodes or bar) intersects any wall?

    Here's a capx of the example. It's pretty simple as I haven't implemented any sort of collision prevention.

    dl.dropbox.com/u/41931267/Linkage.capx

    So, what do you think I should do? I thought of using physics, but that brings problems with clicking and dragging...

    Thanks!

  • *Bump*

    I got pushed off the front page very quickly. Any of you brains out there able to lend some assistance?

  • YOu could make both solid objects, so they don't intersect

    dl.dropbox.com/u/108799982/Capx%20Demos/Draggy.capx

    If that's not suitable, can you upload a .capx of what you have ?

  • The simplest manner would be to have something like two lines, one that is updated if the line does not overlap anything, then another line at 50% opacity that is placed between the two points every time.

    Aside from that, I'm not sure what you want to do. Have it be pushed out? Have it be rotated out? Only update the position of each point if the line is not overlapping anything?

  • The easiest solution is just to change the opacity, or tint it red, or use some other visual indication to mean "invalid".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley I know exactly what you mean, and that idea occurred to me. I might end up using that, actually.

    Arima I sort of want to block the user from making the pipe go inside the wall, while leaving the motion open in other directions.

  • One idea would be to not drag the nodes directly but rather drag ghost nodes. When you drop the ghost it moves back to the node. While dragging you could then do a loop to move the nodes to the ghosts in steps. Each step reposition the bar and if it collides with the box move the node in the opposite direction from the ghost a bit.

    Or something like that.

  • Hmm, not a bad idea, lots to think about ;)

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