Breaking off blocks from a structure

Get help using Construct 2

Post » Fri Dec 06, 2013 4:43 am

Been searching the forums and tutorials for a while with limited success, so here goes;

Not enough rep yet to post a link, but if you open a new project and scroll down to the example that says "Falling blocks", you'll see what I've been working on.

Been working with the "Falling Blocks" example included with C2, hoping to create an element for a game.

In the example, when a block or group of blocks is not connected to the structure of blocks, they slowly sink until they reach the ground or come to rest on another block.

The structure-connection system is perfect for my needs, but what I hope to accomplish is that when the blocks become disconnected, rather than just sinking downwards, they become physics objects and fall and bounce around and the like. I have been trying myself for quite a while, but have been unable to make it work. Either all of the blocks become physics objects and fall at once or sink as usual but without recognizing any connection.

I'm probably just missing something pretty basic, but if someone could help point me in the right direction, that would be wonderful. I've been banging my head against the keyboard for a few days now. :)

Thanks so much!
B
5
S
1
G
1
Posts: 4
Reputation: 584

Post » Fri Dec 06, 2013 5:57 am

I haven't looked at the example, but it sounds like you might want to give them something like a physics behaviour, set it as inactive on start, and then use an event to set it as active.

Here's a quick example of what I mean:
drop-boxes.capx

The boxes have physics disabled as an initial state and an instance variable called 'touched' which is 0. When you click on a box it changes their variable 'touched' to 1. Event 2 makes physics active when touched=1
The result is that when you click on a box it drops to the floor.

You could use one event (when object is touched, set physics to enabled) but the reason I used an instance variable is so that you can change the trigger from clicking on them to a collision, or time, or anything you want.

Hmm, maybe I should have looked at the example, but I hope this is a hint in the right direction anyway.
B
24
S
4
G
3
Posts: 43
Reputation: 2,795

Post » Fri Dec 06, 2013 8:18 pm

Thanks for the reply.
This is the idea I've been trying to implement already, and it works just fine on its own, but when I try to use it in conjunction with the setup nothing works the way it should.

I try enabling physics when the blocks are defined as IsFalling, but all of them just fall right away.

This example is being rather uncooperative.
B
5
S
1
G
1
Posts: 4
Reputation: 584


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, David181, dop2000, tarek2 and 18 guests