Making pushable blocks.

0 favourites
  • 11 posts
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • 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.

  • 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 helps

  • 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.

  • How about:

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

    Bit vague but gives a general idea on the event blocks to look for.

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

    HAXX0RZ This works for me where blue is the player and Sprite 2 is a block with solid behavior:

    <img src="https://dl.dropbox.com/u/10285716/SamplePushBlock.png" border="0" />

    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...

    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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks a ton, that worked.

  • Sketchy77 Awesome, glad to be of assistance!

  • 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.

  • 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

  • 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 -_-

    docs.google.com/file/d/0B0X8AGNTMh-dNDBzMVlSQ01BVGM/edit

  • Anyone have any idea?

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