Platform Collision

For questions about using Classic.

Post » Wed May 02, 2012 6:30 pm

Sorry, another one of these threads, but I couldn't find my answer with the search feature

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 over here.

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

-Silver-2012-05-02 18:33:13
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Wed May 02, 2012 9:52 pm

I'm not sure how much I can help here, but I'll try anyway.

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?
B
16
S
2
G
1
Posts: 156
Reputation: 2,112

Post » Thu May 03, 2012 12:03 am

Thanks for the reply

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 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
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Thu May 03, 2012 1:47 pm

Yay! Single collision boxes solved my issues! Well, solved them well enough. Dropping through them works perfectly now

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

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
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Fri May 04, 2012 8:13 am

No problem!

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. Jim152012-05-04 08:14:28
B
16
S
2
G
1
Posts: 156
Reputation: 2,112

Post » Fri May 04, 2012 11:12 pm

Nah, I'm using a real messed up method of calculating angles. I'm an artist and a writer, so I suck at programming

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

Going to need to take the weekend off though. I'm far too angry about TES Online for any productivity -Silver-2012-05-04 23:14:47
B
15
S
7
G
7
Posts: 250
Reputation: 5,298


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests