Platform Collision

This forum is currently in read-only mode.
From the Asset Store
A pack of 76 platform designs for a platformer game with a mushroom/jungle theme
  • Sorry, another one of these threads, but I couldn't find my answer with the search feature <img src="smileys/smiley9.gif" border="0" align="middle">

    I tend to over-explain things to the point of confusion, so I've uploaded a video showing the problems in action, and a screenshot so you can see how I'm handling the collision for Platform behaviours. I'm assuming the way I'm doing it sucks, and there's a much better way.

    This only happens on slopes. I have flat platforms that don't give me any issues whatsoever, but these slopes are a nightmare. Sometimes the players starts falling through the platforms half-way along (I've tried moving platform boxes in multiple different set-ups, with no luck). The edge of the slopes always turns into a flat surface for some reason, despite the boxes clearly being sloped. And when using the down and jump keys to fall through a platform, the player gets caught up inside the platforms, meaning you have to press down and jump a few times before you drop all the way through.

    I'm trying to get this working for branches in trees. One of the branches on the left is especially problematic. I've even tried copy/pasting the platform boxes from a branch that they're working on to the problem branch, and the player still falls through. I've spent two days trying to solve this now.

    Video is on Youtube

    Screenshot to show collision boxes (with platform behaviour. Branches are tiled backgrounds without any attributes checked).

    Any help and advice would be awesome! Thanks for reading <img src="smileys/smiley1.gif" border="0" align="middle">

    <img src="http://i216.photobucket.com/albums/cc212/darkstorne/CC.png" border="0">

  • I'm not sure how much I can help here, but I'll try anyway. <img src="smileys/smiley17.gif" border="0" align="middle" />

    On the topic of falling through the platforms, the first thing that comes to mind is what kind of collision detection you're using. Are you doing per-pixel for the main character? Do you have a collision box for all animation frames?

    Also, it looks like you have a bunch of different platforms combining to make one slope. I've experienced problems in the past when two slopes were conjoined with each other. Maybe a solution would be to make one slope and rotate it to an angle you like?

  • Thanks for the reply <img src="smileys/smiley1.gif" border="0" align="middle" />

    I have a rectangle box for the player (with all the Platform behaviours and collision detections) and have the box set to be invisible. The wolf sprites are set to always appear at the box's location. Not sure if that's per-pixel <img src="smileys/smiley5.gif" border="0" align="middle" /> Probably is if that's the default.

    I'll try to make a single slope tomorrow and see how it works out. I opted for small slopes so that I could cut down on events. A small slope can be used multiple times for larger slopes, instead of creating a brand new slope platform for every size.

    Thanks for the suggestions. I'll update tomorrow with my progress <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Yay! Single collision boxes solved my issues! Well, solved them well enough. Dropping through them works perfectly now <img src="smileys/smiley1.gif" border="0" align="middle" />

    The slopes still turn into flat surfaces at the ends for some reason, but I'm not overly concerned about that. I guess it could indicate that the player is about to fall off <img src="smileys/smiley17.gif" border="0" align="middle" />

    As for the branch on the left, it turns out that when the player overlaps two different slopes (one going up, the other down) at the same time, the engine just forces him down. No idea why. I've just worked around that by re-arranging the branches a bit so the issue never arises.

    Thanks for your help Jim15 <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No problem! <img src="smileys/smiley1.gif" border="0" align="middle" />

    Also, just curious, but are you setting the angle of your character to something like "Slope.angle"? (Or whatever you've named the slopes?)

    I think the minor problem of your main character standing as if they weren't on a slope towards the end has to do with the collision box overhanging from the slope. That would mean that the programming is telling it to both stand at a normal angle and the sloped angle at the same time, since it technically fulfills the condition that allows the angle to be set to those things.

    I'm having the same problem myself actually, so unfortunatley I can't help out here. I'm sure someone else has the answer though.

  • Nah, I'm using a real messed up method of calculating angles. I'm an artist and a writer, so I suck at programming <img src="smileys/smiley17.gif" border="0" align="middle" />

    Basically, when the player overlaps a slope, I add +1 to the value of a private variable assigned to the player. If he's facing right, and the slope is going down, the private variable starts at 0, and +1 is added every single frame. I then also have a script that always sets the players angle when facing right to be the value of that variable. I put a cap on it so that it can't go over a certain number (degree) based on the slope. In the case of these branches, it's 22 degrees. I also have a similar variable for when he's facing left. I do that for each slope. And then also ensure that when he's on flat ground the calculations work the other way, bringing him back to a normal angle.

    Yeesh. Honestly, it doesn't work all that well. But I'm going to keep trying to tweak with it. I'm planning some more complex additions to smoothen out the transitions between slopes and flat surfaces. I'm sure there's a much better way to go about it though <img src="smileys/smiley17.gif" border="0" align="middle" />

    Going to need to take the weekend off though. I'm far too angry about TES Online for any productivity <img src="smileys/smiley36.gif" border="0" align="middle" />

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