How do I stop an object being dragged through another object?

2 favourites
  • 6 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello again! I've got a platformer where the player stays fixed in the center of the screen (horizontally) but moves up and down. You move the player object through the level by panning (dragging) the level itself back and forth. This works great, but when the player comes to a wall, the wall just pushes the player back, sometimes even off-screen if you drag far enough.

    I fixed this by setting the player position to X = 240 (center of the screen) for every tick. Now the player stays fixed in the center like I want, while still moving up and down.

    But now the walls just move straight through the player even though they are both solid.

    What I'd like to happen is for the level to stop panning when you try to drag it through the player.

    Here is a visual of the level:

    (Ignore the swirl on the player, that's an effect for the end of the level)

    When I pan that wall to the left, into the player, the wall is supposed to STOP moving. The idea is to wait until the player goes up or down and THEN you pass the wall under/over the player to keep moving, but as I said this doesn't work. Now that the player is fixed horizontally the walls/player just pass right through each other.

  • Post a copy of your project (as a single .c3p file) with clear reproduction steps of your issue and it will make it easier to be able to answer your question.

  • Post a copy of your project (as a single .c3p file) with clear reproduction steps of your issue and it will make it easier to be able to answer your question.

    drive.google.com/file/d/1-MLn4d0Ki72nUBrdgL5fMlXW9Acp6Bzs/view

    There is the link to my project. It was designed for touch but works fine with mouse. The problem is a conflict between Event 23 and the main mechanic of the game set up in Event 19.

    The main mechanic is dragging the level (all the platforms as one) under the Player as they repeatedly jump in order to get the player to jump through the portal at the end.

    Unfortunately, when you drag a wall into the player, it pushes the player around. I need them to stay in the center of the screen for the mechanic to work properly.

    To fix this, I added Event 23 which fixes the Player in the center of the screen (horizontally). The new problem is that the wall just goes right through the player now even though they are both solid objects.

    The desired behavior is that the wall (the entire level, really) would STOP moving if it was dragged into the player, as if the player had jumped against a... well, solid wall. The idea is that you time your dragging to slide the platforms/walls under or over the jumping player to avoid them.

  • Sorry to bump, just wondering if anyone else has any ideas to fix this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The design of your game makes it so that you run in those specific issues.

    First, your player should not have the solid behavior, it does not interact with platforms and other solid objects.

    All the platforms are pinned to the Attacher object, so it is difficult to determine platform by platform with the current setup.

    What you could do is deactivate the Solid behavior of the player object.

    Make use of the "Is by wall" Platform condition (https://www.construct.net/en/make-games/manuals/construct-3/behavior-reference/platform#internalH1Link3).

    In an event, check if player is by wall to its left. As an action, set Attacher to drop and move a few pixels to its left compared to its current position.

    Have another event that is the same, except checking right, and moving Attacher to the right.

    This possibly can achieve the mechanic you are willing to put in place.

  • Thank you, I’ll give that a try!

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