Making pushable blocks.

Get help using Construct 2

Post » Thu May 30, 2013 8:53 am

I'm making a simple platformer, my question is; how can I make a solid pushable block (either direction).

I checked the tutorial compilation list, and the only thing I could find is a "rolling boulders tutorial" which was completely different to what I want.

The block is just a simple square block, the player is not animated so I don't need that, and I don't want and don't think I need to use physics since I'm not trying to roll the block.


B
15
S
3
Posts: 29
Reputation: 1,037

Post » Thu May 30, 2013 9:21 am

I just thought this on the fly, so it might not work, but you can try

1. Check whether the player collides with the block
2. Check whether the push button if pressed, if so, change the state of the block to "dragable"
3. While it is "dragable" and arrow button is pushed, move the block with simulate control (8 direction) the same speed and direction as the player
4. If the push button is not pressed, change the state of the block

hope that helpsDaggio2013-05-30 09:22:50
B
45
S
13
G
2
Posts: 173
Reputation: 5,331

Post » Thu May 30, 2013 11:03 am

You could try something like this https://dl.dropboxusercontent.com/u/70305965/push2.capx - its a very basic example, and only good for the simplest of uses, it will fall apart if you try and animate the character whilst pushing and you'll notice the box will move slightly if you jump on it, nevertheless something like this can be modified a bit with some further variables to fix such issues.
B
66
S
25
G
4
Posts: 211
Reputation: 7,057

Post » Thu May 30, 2013 12:40 pm

How about:

On collision>>MoveBlock (X) frames or distance?

Bit vague but gives a general idea on the event blocks to look for.
B
20
S
7
G
4
Posts: 322
Reputation: 4,521

Post » Thu May 30, 2013 4:09 pm

I put together a sample for this a few months back:

[QUOTE=BluePhaze] @HAXX0RZ This works for me where blue is the player and Sprite 2 is a block with solid behavior:



I added a P key is down condition just because I wanted to differentiate between pushing the block and running into it randomly. You can remove that...[/QUOTE]

Another option is to detect your criteria, like on floor, next to wall (block), and the push button held down, and then pin the block to the player. When they release the "push" button unpin the block.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,583

Post » Thu May 30, 2013 11:54 pm

Thanks a ton, that worked.
B
15
S
3
Posts: 29
Reputation: 1,037

Post » Fri May 31, 2013 12:18 am

@Sketchy77 Awesome, glad to be of assistance!
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,583

Post » Fri May 31, 2013 5:22 am

Actually I've encountered another problem. Now when I push the block it goes through all the other solid blocks.

Is their a way to prevent this.
B
15
S
3
Posts: 29
Reputation: 1,037

Post » Fri May 31, 2013 7:40 am

a simple way is to check if it collides with any other solid block, and then stop it from moving, one way to do this is by moving it to the opposite direction with the same speed
B
45
S
13
G
2
Posts: 173
Reputation: 5,331

Post » Fri May 31, 2013 9:26 am

Thanks Daggio, that worked.

Ok, I have another problem (Geez I'm full of them today.) I want to make it so when I push a "pushBlock" into another "pushBlock" it pushes both push blocks and they don't collapse together.


Here is the CAPX.
I would include it as a link, but I can't unless I have 500 rep -_-



https://docs.google.com/file/d/0B0X8AGNTMh-dNDBzMVlSQ01BVGM/edit?usp=sharingSketchy772013-05-31 09:29:36
B
15
S
3
Posts: 29
Reputation: 1,037

Next

Return to How do I....?

Who is online

Users browsing this forum: farsen, gskunk, Kyu, luvleggs, R0J0hound and 61 guests