Tile based collision platformer improvements

D

Dharmatrooper

Guest
Hello, newb here.

Is there any tutorials how to implement ladders, moving and one-way platforms for tile based collision check platformers? Also can't clearly understand how to correctly implement tile based collisions check for characters that bigger than the tile.
 

GMWolf

aka fel666
For characters larger than a tile, you simply have to sample more points along the player.
If an object is just a little bigger than the tile, you van sample the two end points, and a central point.
I briefly go over it in my tutorial:

As for one way tiles and such, I have an example of this on my laptop. I was eventually planning on packaging it into an asset. Still making my decision on that.
But the gist of it is, if you have a platform you can jump through, then the top side of your player cannot collide with the platform, but the bottom side can.
 
D

Dharmatrooper

Guest
For characters larger than a tile, you simply have to sample more points along the player.
If an object is just a little bigger than the tile, you van sample the two end points, and a central point.
I briefly go over it in my tutorial:

As for one way tiles and such, I have an example of this on my laptop. I was eventually planning on packaging it into an asset. Still making my decision on that.
But the gist of it is, if you have a platform you can jump through, then the top side of your player cannot collide with the platform, but the bottom side can.
I have seen your tutorial and several others but there is no clear information how exactly i should do multiple point verifications and would it decrease performance. I have a chacarter which is twice as big as the tile and i will have some elite enemies which will be even more bigger. Also for one way platforms if you will check only bottom part for collision what happens when you jump up through it and the bottom part of character will be inside this tile?
 

GMWolf

aka fel666
I have seen your tutorial and several others but there is no clear information how exactly i should do multiple point verifications and would it decrease performance. I have a chacarter which is twice as big as the tile and i will have some elite enemies which will be even more bigger. Also for one way platforms if you will check only bottom part for collision what happens when you jump up through it and the bottom part of character will be inside this tile?
First of all: dont worry about performance.
I'll assume the system you are using is similar to mine:
Instead of checking two poj ts, you check three points. The code should be pretty simple to modify.
Just add one more line with t3 as a variable, checking the center of whatever side you are currently checking.
Then, instead of checking for t1 or t2, check for t1 or t2 or t3.

As for one way platforms, you only do so with the one way platforms.
Essentially, if you detect a collision with a tile when you player is moving upwards, check if the tile is one way. Only handle the collision if it isnt one way.
 
D

Dharmatrooper

Guest
First of all: dont worry about performance.
I'll assume the system you are using is similar to mine:
Instead of checking two poj ts, you check three points. The code should be pretty simple to modify.
Just add one more line with t3 as a variable, checking the center of whatever side you are currently checking.
Then, instead of checking for t1 or t2, check for t1 or t2 or t3.

As for one way platforms, you only do so with the one way platforms.
Essentially, if you detect a collision with a tile when you player is moving upwards, check if the tile is one way. Only handle the collision if it isnt one way.
Thanks! It looks like i was thinking in the right direction about that stuff. Actually i already tried to check midpoint of character with bbox_top+64 but it seemed laggy sometimes. For example if i'm jumping to the wall on the right the character stops moving as it should and only move up and then fall down but after that weird stuff happens: if i don't touch left/right controls and just hit jump the character starts to fly up continously untill it hit the ceiling and then falls down.
 

TheouAegis

Member
https://games.greggman.com/game/programming_m_c__kids/

This was where I learned about tile-based collisions. The whole article is kinda interesting, but you can just scroll down to "Collisions".

Personally I dislike the current pattern of checking all points at the same time. First off, this is little different than place_meeting() being applied to tiles, and place_meeting() is a crappy collision function. If you are moving forward, you check for a collision at the knees. Is there one there? If yes, stop moving forward; if there isn't, then check for a collision at the chest. Is there one there? If yes, stop moving forward; if there isn't, move forward. If you are falling, check for a collision at the leading foot. Is there one there? If yes, land; if not, then check for a collision at the rear foot. Is there one there? If yes, land; if there isn't, keep falling. When you jump or want to jump, check for a collision at the head. Is there one there? If yes, stop jumping or prevent the jump; if not, then keep on jumping. Then the argument arises, "I need to check each of those every step, so that method is needlessly complicated." No, you don't need to check them all every step. You should only check the ones you need to check and there is no way you would need to check every point every step, since you can't move right while moving left and you can't fall while jumping up.
 
Top