[Solved] How do I detect v-collisions with events only?

  • This problem would also be true for horizontal collisions, since I would be using essentially the same script. Basically, what I'm trying to do is have a Player object detect if they were about to collide with the floor, meaning 10 or less pixels away, there it is. This is part of if I wanted to make a platformer with events only, so that the mechanics were highly customizable, like if I wanted to make a Mario-style platformer with the same player mechanics as in the official games; this can't be done with the Platform Behavior, as least as far as I know.

    Here's the problem script:

    You would think at first, it was supposed to do its job, but the player acted the same way as without it or with it disabled: the player fell through the floor. In fact, in the debug menu, the player wasn't even getting stuck in the floor; there was no effect on the player at all. I'm already stumped. How could I have fixed this script? Or is this the wrong one? I took the general mechanic from GameMaker's same code if that helps.

    By the way, please excuse my frequent questions if you're bothered; let me repeat myself one more time: I don't want to go through any more trial and error, and searching for me is unreliable.

    I did look up how to do it on Google, and I actually got a match, but I didn't quite understand what was going on with the scripts in the post; I couldn't even do Sprite.Right - Right wasn't even an expression for Sprite - nor could I find any sort of expression for Top and Bottom - it wasn't even for C2, it was for Construct Classic. (Can you see why I don't search at all now? It's not even helping.)

    I can make a thread in its own right where I can ask beginner's questions if you feel it's a better solution, by the way.

  • https://www.scirra.com/manual/133/common-expressions

    You're looking for the bounding box expressions?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • oosyrag: Thanks for showing me that; I can't believe I've never noticed them. I'll try using them, and I'll post when I test them out.

    And I'll look through the manual to learn everything I need to know. Just letting you know right now.

    Edit: I've just tested the new script:

    Unfortunately, I got the exact same result; the player falling through the floor and not even getting stuck. I will need further help on the problem. (Remember: I'm new, so I definitely won't be too good a C2 user.)

    2nd edit: I've figured it out myself; the player was falling through the floor mainly because I didn't set 'vsp' to 0 upon being about to collide with it, but I also found out that I could have my initial problem work with the collision and inverted overlapping events and still have pixel perfect vertical collision, as shown with my now-working script:

    This means this problem is now solved. Thanks to oosyrag (you're a lifesaver) for informing me of the BBox expressions. Yes, that was pret-ty dumb of me to ask this in hindsight, but now I've figured it out.

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