[Fixed] Platform engine failing collisions

For questions about using Classic.

Post » Mon May 16, 2011 6:49 pm

Hello there,

After not having touched MMF2 at all for the last couple of years I decided to go ahead and try my hand at game development again, but this time with Construct. However, it seems I got a little rusty. In fact, I can't even get a basic platform engine right anymore! With MMF2 I used to make custom platform engines all the time using loops to I could try to pixel perfect collisions. I'm trying that same approach here, but it looks like I've lost my touch. Can you guys help me?

When you download the CAP first run it. You'll see what's going wrong: the player does stop falling, but actually falls into the ground. It's supposed to rest on top of the red collider bits.

What am I doing wrong? Do the loops work differently here?

[Download]
B
2
S
1
G
5
Posts: 40
Reputation: 1,480

Post » Mon May 16, 2011 7:19 pm

In which version did you do the .cap ? I'm on R1 and can't open the file.
B
6
S
2
G
1
Posts: 122
Reputation: 1,194

Post » Mon May 16, 2011 7:21 pm

This one is made in the latest one, R1.2 :)
B
2
S
1
G
5
Posts: 40
Reputation: 1,480

Post » Mon May 16, 2011 8:38 pm

Well, my guess would be that it doesn't check for overlapping during the loop.

In the layout, if you raise the objPlayer object manually by 5 pixels (should now be at 41 on Y axis), you'll see that the player stops correctly because it's right after a loop.
B
6
S
2
G
1
Posts: 122
Reputation: 1,194

Post » Mon May 16, 2011 9:18 pm

I managed to fix the problem :) I remembered something I'd do with my platform engines in MMF2. What I did now is basically this:

[code:271gskcn]
On loop "moveY"
If inertiaY is greater than 0
move objPlayer down the Y axis by 1 pixel
[/code:271gskcn]

After which there is a collision detection. However, as with the logic I got used to with MMF2, the position of detectors (and the player sprite for that matter) isn't updated yet. This can either be fixed by moving the collisions before the positioning events, or by moving the detectors together with the main player object. That last thing is what I did.

[code:271gskcn]
On loop "moveY"
If inertiaY is greater than 0
move objPlayer down the Y axis by 1 pixel
move objBCollider down the Y axix by 1 pixel
[/code:271gskcn]

Now it's functioning properly :)
B
2
S
1
G
5
Posts: 40
Reputation: 1,480


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest