2 Sprites collision problem

0 favourites
  • 4 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • Hey, I have a character made of 2 150px by 150px sprites and I want to move him on a grid, so I tried this:

    Basically, when I push "A" or Left Arrow, I move the bottom half 150px to the left (And since the top half will be pinned to the bottom half - 150px in the Y direction, it will move the top one too)

    Then I check if the bottom half is overlapping the sprite "Ground" (So it would not go trough it) and if it is, I would add 150px to the bottom half, moving it back to it's place.

    The problem comes when I apply the same code to the top half, but this time it does not work...

    I also tried: If Bottom Half is overlapping Ground|

    or | => then Bottom Half set X to self.X + 150px

    If Top Half is overlapping Ground |

    But this didn't work either...

    What am I doing wrong?

    (Here is the capx: https://www.dropbox.com/s/b1lp1puv1i81t ... .capx?dl=0)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think you are not particularly doing something wrong, I just think C2 does not register yet the overllap, after muliple attempts that is the conclusion I am coming to.

    I used another method, using the might of overllaping at offset, hope it works fine for your purpose: https://1drv.ms/u/s!AjkoCSebIn9JjCEO0d_UMx6pohZh

  • I don't understand, you don't want the character to be able to move if the top half is next to a wall, is that right?

    So you shouldn't say "if top half is overlapping ground -> move left", you should say "if top half isn't overlapping ground on the left -> move left".

    In this case you should use "is overlapping at offset".

    You're also checking and moving for both bottom and top half. You're basically saying "if bottom part is overlapping ground and player presses left -> move left -> then check if the top half part is also overlapping ground -> move left again".

    If you're trying to make it so the both parts can only move when there's no ground on where they are trying to move, you should do this:

  • I think you are not particularly doing something wrong, I just think C2 does not register yet the overllap, after muliple attempts that is the conclusion I am coming to.

    I used another method, using the might of overllaping at offset, hope it works fine for your purpose: https://1drv.ms/u/s!AjkoCSebIn9JjCEO0d_UMx6pohZh

    I don't understand, you don't want the character to be able to move if the top half is next to a wall, is that right?

    So you shouldn't say "if top half is overlapping ground -> move left", you should say "if top half isn't overlapping ground on the left -> move left".

    In this case you should use "is overlapping at offset".

    You're also checking and moving for both bottom and top half. You're basically saying "if bottom part is overlapping ground and player presses left -> move left -> then check if the top half part is also overlapping ground -> move left again".

    If you're trying to make it so the both parts can only move when there's no ground on where they are trying to move, you should do this:

    Thank you very much for the help, guys!

    I did not know that overlap at offset was a thing =D

    I was first moving the player and then checking to see if he was overlapping with the ground (and if he was, I would move him back)

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