Handling curves in a platformer?

    How in the dun diddly would you handle curved/diagonal tiles in a platformer? Surely there is a mathematical equation that I can't seem to find right? What I want is for the character to run smoothly up these tiles.

I haven’t implemented that type of collision detection and response myself, but there’s a well-known tutorial here that discusses the SAT with respect to curved shapes. I think this is the game with which the tutorial is associated. It looks like most of the levels don’t feature curved tiles, but if you watch the demo for a while you may see some levels with curved elements.

There might be simpler solutions, but we’d probably have to know more about what you have in mind (tile shapes, convex or concave, etc.).

[quote=“MrPork,post:1,topic:55133”]
I’m not trying to be sarcastic, but it depends on how exactly you want to handle them. I assume you’re talking about a 2D grid of blocks, some of which can have curved tops?

[quote=“MrPork,post:1,topic:55133”]
Yeah, the equation is simply the equation of the curve. Let’s say you have triangular block with a top that goes from the lower-left of its cell to the upper-right of its cell. If you land on that block, your y (bottom) position is just the y (bottom) of the block, plus the y value of the top of the block at the x (right?) position of your character.

Something like this:

player.y = block.y + block.heightAt(player.x);

[quote=“MrPork,post:1,topic:55133”]
Personally, I would just use a physics engine.

If you want something fancier than the simple case I described above, I remember a series of tutorials on Sonic the Hedgehog game physics that I thought was pretty good. I can’t google for them now, but if you can find them that might be a good place to start.

I believe this is the tutorial @KevinWorkman was referring to. Good stuff indeed. 8)

Yep! After going through some old bookmarks, I came across this, which is just the parent category of the article you posted.

I also came across Open Sonic, which sadly seems to be shut down. I don’t really remember what that was, but it sounds interesting.

Can you tell that I went through an optimistic phase where I thought about creating my own Sonic game? :stuck_out_tongue:

Short answer is: Its just not that simple. You will invest a lot of time writing a mini physics system.
Horizontal logic, vertical logic, gravity, jumping , forces, platforms that may move you up or down if you have that, side to side, what happens if you do get stuck into a wall or floor.

its an iterative process where you test and test.
I dont even have curves, I have lines of technically arbitrary angle. but even that is hard to do graphic wise when working with tiles.
Then also in my latest system I have a shit ton of callbacks like, hit the ground, pushing against wall, walking down, walking up, jumping jump, falling down and many more - these are for animations, so that the animation can switch all the time.

So there is no equation that comes to the rescue, you have to think about all the glitching that may happen anyway, and it really also depends on your animation system your tile/map system, objects in the game and in general how you can move around

Performance is also an issue somewhat as you will have to do subpixel calculations every frame.

So that was all very theoretical:

Start with: The same that you are doing know to ensure your character stays on top of tiles, do that for lines…

I appreciate everyone’s help! I am reading the sonic tutorial as I post this! ;D

I made this once using pixel perfect collision detection without making slow because I was still using grid system