# Drag and throw a ragdoll with touch

Get help using Construct 2

### » Sun Dec 01, 2013 6:32 pm

I'm trying to be able to drag and throw a ragdoll with touch. The controls now are way too jumpy, and I don't know how to approach this. Does anyone have an idea?

The Project

Relevant Code

Thanks!
B
77
S
26
G
11
Posts: 455
Reputation: 12,758

### » Sun Dec 01, 2013 8:14 pm

Drag and drop object

on touch set x,y start points
on release set x,y end points

get angle(start.x,start.y,end.x,end.y)
get distance(start.x,start.y,end.x,end.y)

To determine speed for object through something ike impulse applied:

with a simple approach, use the distance as a reference for power. ie The longer someone dragged, the bigger the impulse applied.

Or you could do something fancy, like, setting begin and end time of the drag too and comparing to distance traveled, then apply impulse proportianally.
Who dares wins
B
57
S
17
G
21
Posts: 1,880
Reputation: 19,628

### » Sun Dec 01, 2013 9:48 pm

[QUOTE=lennaert] Drag and drop object

on touch set x,y start points
on release set x,y end points

get angle(start.x,start.y,end.x,end.y)
get distance(start.x,start.y,end.x,end.y)

To determine speed for object through something ike impulse applied:

with a simple approach, use the distance as a reference for power. ie The longer someone dragged, the bigger the impulse applied.

Or you could do something fancy, like, setting begin and end time of the drag too and comparing to distance traveled, then apply impulse proportianally.[/QUOTE]

Thanks, but I think you misinterpreted my original post or I didn't phrase it well, but I'm not trying to get a catapult effect, I want to be able to drag a rag-doll independently and have it's velocity and whatnot carry through once released. But this must all be done through physics otherwise it will mess up all the collisions and such.
B
77
S
26
G
11
Posts: 455
Reputation: 12,758

### » Sun Dec 01, 2013 9:52 pm

Thats actually what the effect intended is ...

Upon release object calc values to aply impulse @ angle
Who dares wins
B
57
S
17
G
21
Posts: 1,880
Reputation: 19,628

### » Sun Dec 01, 2013 10:33 pm

[QUOTE=lennaert] Thats actually what the effect intended is ...

Upon release object calc values to aply impulse @ angle[/QUOTE]

Alright, it looked very similar to a method I used for a catapult effect in something else. Won't it still interfere with the physics though? I've already tried a method with position.
B
77
S
26
G
11
Posts: 455
Reputation: 12,758

### » Sun Dec 01, 2013 10:43 pm

I'm guessing the mechanics are about the same, throwing is just other direction, and the trigger is near same imo..

Mechanics just differ slightly hehe
Who dares wins
B
57
S
17
G
21
Posts: 1,880
Reputation: 19,628

### » Sun Dec 01, 2013 10:54 pm

[QUOTE=lennaert] I'm guessing the mechanics are about the same, throwing is just other direction, and the trigger is near same imo..

Mechanics just differ slightly hehe[/QUOTE]

Unless I'm reading the code wrong, this isn't a real time method, it doesn't drag, so much as teleport.
B
77
S
26
G
11
Posts: 455
Reputation: 12,758

### » Sun Dec 01, 2013 11:16 pm

hmm, I ditched the drag and drop nd tried this:

web example

capx

Its crude.

Drag and throw gentle.

Havent tested how it works on touch..
Who dares wins
B
57
S
17
G
21
Posts: 1,880
Reputation: 19,628

### » Sun Dec 01, 2013 11:48 pm

[QUOTE=lennaert] hmm, I ditched the drag and drop nd tried this:

web example

capx

Its crude.

Drag and throw gentle.

Havent tested how it works on touch..[/QUOTE]

Well see that creates issues with other physics objects, look at this:

here

that, and once your pointer goes off it stops, which is why I used if is in touch after the initial touch.
B
77
S
26
G
11
Posts: 455
Reputation: 12,758

### » Mon Dec 02, 2013 12:04 am

Then lets prevent that :)

links and capx updated

web example

capx
Who dares wins
B
57
S
17
G
21
Posts: 1,880
Reputation: 19,628

Next