one object dragging another object around

Get help using Construct 2

Post » Sun Oct 30, 2011 5:30 pm

Hello! I'm struggling to make something like this:
We have three objects interacting with each other: ufo, hook and worm.

On mouse click UFO sends Hook in space to some max distance. If hook overlaps with worm then hook should attach itself to worm which is moving and dragging hook. Hook should set its angle to the angle of worm. And UFO should be dragged with the hook with its angle.

I tried to do it using this new behaviour: Pin. But when I pin ufo to hook and hook to worm and I rotate hook toward angle of worm then only UFO rotates and I can't rotate hook. You can download this project here: http://www.speedyshare.com/files/30993894/spaceLassoTest.rar You send hook with the left mouse button and you have to send it so it hits the worm. In this version I added as few mechanics as I needed for this, because I'm really struggling to make it work...

Maybe I should use physics instead?
Member of PLUS(S). Check out our games at: http://pluss.newgrounds.com/
B
8
S
1
G
1
Posts: 23
Reputation: 838

Post » Mon Oct 31, 2011 6:37 am

http://dl.dropbox.com/u/1378330/lasooFix.capx

Try that. I got rid of the behaviours and did it with events.
B
55
S
12
G
8
Posts: 339
Reputation: 9,314

Post » Mon Oct 31, 2011 7:55 am

You could make "set position to hook.x, hook.y at imagepoint 1" (the place where you want the worm to be.

Cheers
B
17
S
4
G
4
Posts: 94
Reputation: 3,058

Post » Mon Oct 31, 2011 10:52 am

Thanks! It works great. I didn't want the hook wait until it gets it max length, so I changed it a little. I have one question, though:

Each tick you set value: distanceFromHook to its real distance, but when you move ufo so it will follow the hook you have to subtract 200. Why distanceFromHook resets to almost zero when the hook sticks to worm and ufo instantly follows it?

@Spades Thanks! I know I have the possibility like this, but @cow_trix methos is interesting because hook just sticks to the object in the point where it collided with it. But probably in the end sticking to one imagepoint will be better.
Member of PLUS(S). Check out our games at: http://pluss.newgrounds.com/
B
8
S
1
G
1
Posts: 23
Reputation: 838

Post » Mon Oct 31, 2011 12:19 pm

[QUOTE=samur]Each tick you set value: distanceFromHook to its real distance, but when you move ufo so it will follow the hook you have to subtract 200. Why distanceFromHook resets to almost zero when the hook sticks to worm and ufo instantly follows it?[/QUOTE]

Sorry Samur, I don't quite understand. The variable distanceFromHook shouldn't reset to nearly zero. The reason I set the move amount to 200-distanceFromHook is so that the further away the UFO is from the worm, the faster it moves.
B
55
S
12
G
8
Posts: 339
Reputation: 9,314


Return to How do I....?

Who is online

Users browsing this forum: MarkThomas and 18 guests