How do I create a ragdoll in specific place?

0 favourites
  • 11 posts
From the Asset Store
Spooky Places game assets for 2D endless runner action adventure game.
  • Hello, guys, I'm trying to create and position a ragdoll in the specific place of my game layout. In this simple experiment I used tutorials 'Rag doll example' and added two new actions - put invisible 'target' sprite to the mouse pointer and set ragdoll body position to it.

    As a result, ragdoll flies away and never comes back, instead of 'hanging' from the mouse pointer and then falling down. What's wrong?

  • ankas

    There are a couple of things going on here:

    1) When the project starts, sometimes mouse x,y will be registered as 0,0 (I think this is when the mouse is out of window at the start). Even if it isn't there is likely to be a displacement between mouse x,y and body x,y.

    2) All those limb objects have the physics behaviour on them, so when Body is moved in the start of layout event they all suddenly get an impulse applied, which immediately propels them towards the target. This impulse continues in subsequent frames, shooting the whole ragdoll off the screen. Try disabling all of the "Create Physics revolute joint" actions at the start and you will see that the impulse is eliminated.

    The easiest way to fix this would be to shift the "target|Set position" and "body|Set position" actions above the "Create Physics..." actions and to swap the mouse co-ordinates for a fixed screen position.

  • [quote:1lkzaluu]@mekonbekon

    Thank you, it works, not very well though.... What I did:

    1. Position body to 'player' visible sprite.

    2. Position head, arms, and legs to body.

    3. Enable physics.

    4. Make joints.

    5. Apply torque to the body in the angle of 'player' movements. It seems it does not work.

    Can you take a look at my capx, please?

    https://www.dropbox.com/s/7guft5u0nvshm ... .capx?dl=0

  • Here you go:

    https://www.dropbox.com/s/slm6gai7z026l ... .capx?dl=0

    I had to fiddle around with the origins on the limbs to get them into place

  • Thank you! It works!

  • Cool! Glad to help out

  • [quote:33g6kox8]@mekonbekon

    Thank you for your help, but now I experienced another problem. And the problem is how to enable my ragdoll.

    With a 'mouse click' it works just fine, but when I use 'hitpoint=<0' or 'alive=0' (variables) conditions, the positioning continues to work every tick, as variable is not changing anymore. Thus the 'body' of the ragdoll is hinged to specific point, rotating as crazy.

    Any idea how to fix this issue and what is the best way to enable ragdoll?

  • ankas I'm not quite sure what you mean - could you post a capx?

  • [quote:3spsm5q1]@mekonbekon

    Sorry for the delay with the response, probably we are in very different time zones.

    I added a variable 'hitpoint' which can be reduced, using double-click. When it reaches '0', I want to replace my sprite animation (not implemented yet) with a ragdoll, positioned on invisible 'player' sprite (I made it visible for better control and understanding of what is going on).

    Thanks for your time.

    https://www.dropbox.com/s/7guft5u0nvshm ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ankas

    The points check is firing every tick, which is messing things up for you. I think this should work ok:

  • Thank you, I will try this at evening. I guess it should work.

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