Difficult collision problem

Get help using Construct 2

Post » Thu Dec 13, 2012 8:50 pm

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.



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.



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.

https://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!
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Dec 14, 2012 8:31 pm

*Bump*

I got pushed off the front page very quickly. Any of you brains out there able to lend some assistance?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sat Dec 15, 2012 1:42 am

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

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

If that's not suitable, can you upload a .capx of what you have ?
Using R238 for all examples
B
60
S
17
G
6
Posts: 363
Reputation: 9,125

Post » Sat Dec 15, 2012 1:48 am

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?
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sat Dec 15, 2012 2:02 am

The easiest solution is just to change the opacity, or tint it red, or use some other visual indication to mean "invalid".
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sat Dec 15, 2012 2:21 am

@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.sqiddster2012-12-15 02:21:27
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sat Dec 15, 2012 9:42 am

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.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Sat Dec 15, 2012 1:26 pm

Hmm, not a bad idea, lots to think about ;)
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400


Return to How do I....?

Who is online

Users browsing this forum: armaldio, blackhornet, makkancs, TiagoCesar and 17 guests