HaxeFlixel / HaxeFlixel/flixel
Classic Physics: Slopes & Advanced Platforming
Nobody has claimed this yet.
- Dominant language
- Haxe
- Stars
- 2.2k
- Forks
- 522
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
I've been having this problem for a while, and I really think that having this built-in would benefit the community. @JoeCreates raised the issue in Slack, and I figured it was time to have a serious discussion about it.
The Problem
Flixel's non-NAPE physics work well when you have simple level geometry, such as what FlxTilemap offers. Things however get hairy when you try to adding more "advanced" platformer level elements, such as slopes, one-way floors, or even one-way slopes. As we can see from the FlxTilemapExt Demo, it works but doesn't feel as good as it should.
- When moving up a slope, the object seems to be going incredibly fast, as the distance you're travelling is greater than your horizontal speed.
- When moving down a slope, the player should "stick" to the floor, and not float off it.
- Hitting a sloped ceiling behaves weirdly: it shouldn't feel like you're going faster (related to the first point)
What's Expected
@JoeCreates has (long ago, in FlashPunk) created a demo which displays how slopes are expected to behave. The red floating slope is a one-way slope meaning that you can get in from the right side, but colliding properly on the left. Unrelated, but could also be implemented in FlxTilemapExt.
- Going up the slope, the horizontal velocity should be the same as walking on non-sloped terrain;
- This has to be implemented at the
FlxObjectlevel. (e.g. not only forFlxTilemapExt); - Only convex, rectangular hitboxes have to be implemented, as classic Flixel physics don't support any other type of hitboxes (unless I'm mistaken);
- Although I don't think this is required, rotated hitboxes would also collide properly;
- All slope angles (from horizontal to vertical) should be supported.
Potential Solution(s)
I am not qualified enough to dive into physics, but @larsiusprime and @Beeblerox have pointed out multiple resources that could potentially help:
- N/N+/N++ tutorials: Part A and Part B
- Raigan pointed out Paul Firth's tutorials
Bounty
I know this is a big issue and a lot to think about (and also that I probably don't understand the implications), but I am offering a small 100$ bounty for this issue to get implemented/fixed.
The bounty is payable upon verifying that the classic HaxeFlixel physics work properly with slopes (the What's Expected list works), and that I am satisfied with the results.
(this is mostly a write up of a Slack conversation)
cc @JoeCreates @Beeblerox @larsiusprime
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading FlxObject and the FlxTilemapExt Demo, then compare their current slope behavior with the linked N/N+/N++ and Paul Firth collision resources. Done means classic Flixel physics support the listed slope, one-way slope, ceiling, velocity, hitbox, and angle requirements at the FlxObject level.
Written by the indexing model from the issue text.
Assessment
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100