Home Artists Posts Import Register

Content

http://shaunspalding.co.uk/files/TileCollisionsPlatformer.yyz

A few people had been having issues adapting tile collisions to a platformer. Now I said often "Just add gravity". Which largely is the case, but you also have to check for jumping (It's done the same as the other collisions, two bottom points +1 in the y direction!) and also a lot of people found themselves running into odd issues they didn't understand.

I feel like the main root of these issues was people understandably plugging in non-integer numbers for their speeds (Probably gravity, where "1" is generally a bit too strong at 60fps and 0 is... 0.). The solution to this is to properly add, remove and store fractions every frame, keeping the overall effect of moving "3.5" pixels a frame but only using a whole integer each frame (3.5 would end up as 3 then 4 then 3 then 4).

This doesn't just solve the tile issue, but makes a number of things easier as you never ever have to worry about your player being in a non-integer, sub-pixel position.

I've put together an example of the tile collision system used in a platformer with a fraction storage system, originally for some patrons who had questions/were stuck, but I may as well release this to everyone and may follow this up with another video on the topic at some point soon.

Files

Comments

Anonymous

For bottom collisions it telleports my character above the hit box rather than below?

Raeldor

Thanks! I'll try whenever I can