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

Just started using Construct 2? Post your questions here

Post » Mon May 08, 2017 6:25 pm

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:
Image

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.
Last edited by MushroomKingdomr on Wed May 10, 2017 7:01 pm, edited 1 time in total.
B
14
S
6
G
2
Posts: 21
Reputation: 2,146

Post » Mon May 08, 2017 9:47 pm

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

You're looking for the bounding box expressions?
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Mon May 08, 2017 11:23 pm

@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:
Image

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:
Image

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.
B
14
S
6
G
2
Posts: 21
Reputation: 2,146


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests