Push sprite with other sprite as if it has no mass

0 favourites
  • 11 posts
From the Asset Store
Push the Box Puzzle Game likes Sokoban made with Illustrator
  • I have two sprites, one is the character with 8 directional movement. The other sprite is a simple block.

    When the character hits the block I want him to push it.

    I don't want the character to slow down at all when hitting the block (I tried physics with block set to 0 mass and it would still slow the character down).

    I don't want the block to continue moving after the character stops (I tried physics and the block would continue to slide a little).

    I would also like to limit the block to move only one direction at a time between left, right, up, or down. This would ideal but not necessary.

    Any help on how I would be able to accomplish this?

    Thank you in advance.

  • I've tried this and it works as expected until I turn the acceleration up of the green colored "Sprite" to "600."

    I hit the red colored "Sprite 2" and basically pass right through it.

    Any suggestion for instant feedback no matter the speed?

  • Here's an improvement:

    while

    sprite: is overlapping sprite2

    --- sprite2: move 1 pixels at angle Sprite.8Direction.MovingAngle

    You can still run into the issue of sprite passing through sprite2 if it's speed is so high that one frame sprite is on one side of sprite2 and the rest it's on the other without colliding. But this is usually not an issue and the solution is to check the inbetween positions for collisions.

  • Yeah, I didn't see much change with that. As I'm pushing Sprite2 with Sprite as the speed increases Sprite simply pushes through Sprite 2 and leaves it sitting in its tracks.

  • Did you include the while condition?

    If you did and it still leaves it behind how fast is Sprite going?

  • Maybe I'm doing it wrong.

    I added it without the System:While and once I add that the game fails to launch.

    I'm adding it after everything else in the event sheet as follows:

    Line #5

    System:While

    Line #6

    (Indented underneath Line # 5) Sprite:Is overlapping Sprite 2:Sprite 2: Sprite.8Direction.MovingAngle

  • Sprite has a max speed of 600.

  • Guesswork is not helping anyone. This is why it is always best to provide a .capx so we can see what you've done and provide a much quicker and hopefully positive response.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe I'm doing it wrong.

    I added it without the System:While and once I add that the game fails to launch.

    I'm adding it after everything else in the event sheet as follows:

    Line #5

    System:While

    Line #6

    (Indented underneath Line # 5) Sprite:Is overlapping Sprite 2:Sprite 2: Sprite.8Direction.MovingAngle

    "Sprite:Is overlapping Sprite 2" should be another condition to event 5 instead of a subevent..

  • Ah! That worked. Thank you.

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