How do I duplicate ragdolls [SOLVED]

Get help using Construct 2

Post » Wed Apr 23, 2014 12:06 pm

Hi everyone. I'm new to Construct 2 development.
I like how one can make complicated things in 2 clics, but unfortunatly, I'm struggling with somewhat simple things since several days...

So here it is: I'm making a game with ragolls falling from the sky. Lots of ragdolls.
My problem is that I have no idea how to duplicate them (AKA system/create).
Do I have to attach each limbs again after having created the ragdoll?

Thanks for your help :)
Last edited by Txori on Sat May 10, 2014 3:16 pm, edited 3 times in total.
B
8
S
2
G
1
Posts: 16
Reputation: 612

Post » Wed Apr 23, 2014 3:06 pm

One way would be to put all of the rag doll elements into one Container. Then have a Function that is called when On Create RagDollHead is triggered (assuming RagDollHead is the parent of the container); you only then need to place/create the RagDollHead sprites on your layout and the Container will take care of the rest. In the On Create Function you'll have to code the positioning of the limbs and creating the joints etc, but you'll only have to code it once in your game.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Post » Wed Apr 23, 2014 3:45 pm

Could you not just spawn the container, and that container have the 'connected up ragdoll' in it? Or is that not possible?
B
6
S
2
Posts: 89
Reputation: 682

Post » Wed Apr 23, 2014 4:21 pm

Not an option - the container only lists the sprites that are associated with each other. You've still got to tell the physics engine how to connect them together.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Post » Thu Apr 24, 2014 9:41 am

Hi, thanks for your help!!
So I used container and function but I have trouble attaching the limbs correctly to the body. It don't seems to take the set angle into account. Furthermore, attaching limbs to the body seems to give it some force at a random angle. Or maybe is there something that I don't understand?
I've attached a short exemple. Just press spacebar to create a ragdoll.
You do not have the required permissions to view the files attached to this post.
B
8
S
2
G
1
Posts: 16
Reputation: 612

Post » Sun Apr 27, 2014 12:54 pm

Help, I'm still trying to attach the limbs correctly to the body once it has been duplicated...
I've tried "set position" or "set position to another object" but nothing is taken into account, and the body appears with a force that seems to be related to the limbs attached to it... I don't understand.
Thanks for your help !
B
8
S
2
G
1
Posts: 16
Reputation: 612

Post » Wed Apr 30, 2014 11:09 am

Hi, I've spent one week trying to attach the limbs correctly to the duplicated ragdoll without luck.
It should be very basic but I don't understand the logic here.
The limbs don't take the position into account and they're giving a force to the body when they are attached to it...
Here's a simple example, with only the body and the head, you'll see what I mean.
Does anybody know how to do that please?
You do not have the required permissions to view the files attached to this post.
B
8
S
2
G
1
Posts: 16
Reputation: 612

Post » Wed May 07, 2014 12:45 am

@Txori,

I've fixed it!

Some comments for your future enjoyment of programming with C2:

- Take a good look at the shapes of the arms and legs - you had them as squares and stretched them in the editor. They looked ok but I'm not sure this stretching was helping the physics engine.
- The head object you had was 256x256 and was shrunk in the editor. Again, not sure what that would have done to the physics engine, so I resized it to 30x30.
- The image origins are now positioned on the right/left limbs at where the joint should be - you had them in the center. This was causing the physics joint to link from the body imagepoint to the center of each limb rather than the shoulder/hip.
- I have shuffled your events around a bit. Now you have an on-create event that positions everything properly once the body is created. In hindsight this might not be required, but for the point below you can't create everything in a Function (unfortunately).
- The on-create body event now has a 0.05 sec delay - this allows the physics engine to catch up with the new objects it has to consider. It doesn't work if you remove this. Luckily you can't notice this.
- I've used a container to contain all of the limbs to minimize code.

Here's the finished capx - enjoy!
You do not have the required permissions to view the files attached to this post.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Post » Wed May 07, 2014 9:16 am

Thank you so much Colludium!
I've learn so many things with your explanations. As I started from the example given with Construct 2, I thought that square and stretched limbs would work. And I would have never find out about the .05s time delay...
I'll make a good use of your example!
Last edited by Txori on Fri May 09, 2014 12:28 am, edited 1 time in total.
B
8
S
2
G
1
Posts: 16
Reputation: 612

Post » Wed May 07, 2014 11:08 am

:)
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests