How do I push a box normally

0 favourites
  • 7 posts
From the Asset Store
Push the Box Puzzle Game likes Sokoban made with Illustrator
  • Hello!

    So, I am trying to figure out how different game mechanics can be realised through Construct 2.

    Now, I am trying to make the player to push the box in front of him.

    I figured out two ways (while digging this forum): one involves Solid behavior (but it results in stuttering walk animation of a Player) and the other is without "solidifying" the object (but that results in a fact that player can't jump atop of the box).

    Is there any way to make the animation play smooth, while using Solid behavior? Or is there a way to make the Player to stand atop of the box, without attaching the Solid behavior to it?

    Thanks in advance!

    media.giphy.com/media/3o7btUVczBiSPU1YLm/giphy.gif (box_1 here is without Solid behavior and box_2 is with Solid behavior)

    i.imgur.com/VurK4Y5.jpg (here's my events sheet)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should apply Physics behavior to your player and the box to make it nice and realistic.

  • You can also check the Physics Catapult example / template that comes with C2:

    http://prntscr.com/fm2pzb

  • You should apply Physics behavior to your player and the box to make it nice and realistic.

    I am trying to avoid using physics, because it brings a lot of complexity in the project (and random stuff starts to happen). Thanks for the advice, though!

  • You could do this with the platformer behavior + a little bit of custom work:

    1. Create an instance variable for the player called prevx.

    2. Create an invisible sprite for the top of the box.

    3. Set the top sprite to solid so that the player can land on it.

    4. Every tick set boxtop.x + box.x

    5. Box -> is overlapping player -> set box x = self.x + player.x - player.prevx

    6. Every tick set player.prevx = player.x

  • You could do this with the platformer behavior + a little bit of custom work:

    1. Create an instance variable for the player called prevx.

    2. Create an invisible sprite for the top of the box.

    3. Set the top sprite to solid so that the player can land on it.

    4. Every tick set boxtop.x + box.x

    5. Box -> is overlapping player -> set box x = self.x + player.x - player.prevx

    6. Every tick set player.prevx = player.x

    Sounds promising, I'll try it. Thanks a bunch!

  • Well, I've tried the method above, but it did not work for me (for some reasons). So, I tried multiple ways, including using timer and other tools.

    Finally, I found an easier way to do the trick (maybe anybody will find it useful).

    So, I make a box and set Platform and Solid behavior to them. I set Solid behavior initial state as "disabled".

    Then, I create an event which concludes of two conditions. First: Player box is overlapping box at offset (0, 10). Second: Player box Y coordinate is less than box's Y coordinate. Then, assign an action: set Solid behavior enabled for box. Add sub-event: Else, box's Solid behavior is disabled.

    This way lets you move boxes (I guess that precision can be achieved with tinkering with the Platform behavior of box) and it does not interrupt the walking animation of a player.

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